aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-20 00:08:21 -0700
committerFuwn <[email protected]>2022-04-20 00:08:21 -0700
commit904ac81e7e754e87e0d64de59a75d38af63efdca (patch)
tree23387a69a3d66999eb40255b4b0ea46d78036860
parentrefactor(main): create flexible rount mount timer (diff)
downloadlocus-904ac81e7e754e87e0d64de59a75d38af63efdca.tar.xz
locus-904ac81e7e754e87e0d64de59a75d38af63efdca.zip
refactor(macros): crate batch mount file macro
-rw-r--r--src/macros.rs9
-rw-r--r--src/main.rs42
2 files changed, 30 insertions, 21 deletions
diff --git a/src/macros.rs b/src/macros.rs
index 47a85cb..7d7761f 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -82,3 +82,12 @@ macro_rules! mount_file {
);
};
}
+
+#[macro_export]
+macro_rules! batch_mount_file {
+ ($router:ident,$(($path:literal, $description:literal, $file:literal),)*) => {
+ $(
+ mount_page!($router, $path, $description, $file);
+ )*
+ };
+}
diff --git a/src/main.rs b/src/main.rs
index 9abb28c..4d7e781 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -166,28 +166,28 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
"This Gemini capsule's icon",
"favicon.txt"
);
- mount_page!(router, "/", "This Gemini capsule's homepage", "index");
- mount_page!(router, "/contact", "Many ways to contact Fuwn", "contact");
- mount_page!(router, "/donate", "Many ways to donate to Fuwn", "donate");
- mount_page!(
+ batch_mount_file!(
router,
- "/gemini",
- "Information and resources for the Gemini protocol",
- "gemini"
- );
- mount_page!(
- router,
- "/gopher",
- "Information and resources for the Gopher protocol",
- "gopher"
- );
- mount_page!(router, "/interests", "A few interests of Fuwn", "interests");
- mount_page!(router, "/skills", "A few skills of Fuwn", "skills");
- mount_page!(
- router,
- "/licensing",
- "The licensing terms of this Gemini capsule",
- "licensing"
+ ("/", "This Gemini capsule's homepage", "index"),
+ ("/contact", "Many ways to contact Fuwn", "contact"),
+ ("/donate", "Many ways to donate to Fuwn", "donate"),
+ (
+ "/gemini",
+ "Information and resources for the Gemini protocol",
+ "gemini"
+ ),
+ (
+ "/gopher",
+ "Information and resources for the Gopher protocol",
+ "gopher"
+ ),
+ ("/interests", "A few interests of Fuwn", "interests"),
+ ("/skills", "A few skills of Fuwn", "skills"),
+ (
+ "/licensing",
+ "The licensing terms of this Gemini capsule",
+ "licensing"
+ ),
);
});