aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2022-04-20 00:18:23 -0700
committerFuwn <[email protected]>2022-04-20 00:18:23 -0700
commitc573f1ea806a44b89b3e4b84e02b68f838f1279b (patch)
treeb4bf0960b16dc6fb4c89bb0cf14713d40cc1f1e8 /src
parentfix(macros): rename macro to page (diff)
downloadlocus-c573f1ea806a44b89b3e4b84e02b68f838f1279b.tar.xz
locus-c573f1ea806a44b89b3e4b84e02b68f838f1279b.zip
refactor(macros): batch_mount files
Diffstat (limited to 'src')
-rw-r--r--src/macros.rs9
-rw-r--r--src/main.rs22
2 files changed, 18 insertions, 13 deletions
diff --git a/src/macros.rs b/src/macros.rs
index ce2c403..025e0dc 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -84,10 +84,15 @@ macro_rules! mount_file {
}
#[macro_export]
-macro_rules! batch_mount_page {
- ($router:ident,$(($path:literal, $description:literal, $file:literal),)*) => {
+macro_rules! batch_mount {
+ ("pages", $router:ident, $(($path:literal, $description:literal, $file:literal),)*) => {
$(
mount_page!($router, $path, $description, $file);
)*
};
+ ("files", $router:ident, $(($path:literal, $description:literal, $file:literal),)*) => {
+ $(
+ mount_file!($router, $path, $description, $file);
+ )*
+ };
}
diff --git a/src/main.rs b/src/main.rs
index 1b185e9..8be963f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -154,19 +154,19 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
});
time_mounts("static", &mut time_mount, || {
- mount_file!(
+ batch_mount!(
+ "files",
router,
- "/robots.txt",
- "Crawler traffic manager, for robots, not humans",
- "robots.txt"
- );
- mount_file!(
- router,
- "/favicon.txt",
- "This Gemini capsule's icon",
- "favicon.txt"
+ (
+ "/robots.txt",
+ "Crawler traffic manager, for robots, not humans",
+ "robots.txt"
+ ),
+ ("/favicon.txt", "This Gemini capsule's icon", "favicon.txt"),
);
- batch_mount_page!(
+
+ batch_mount!(
+ "pages",
router,
("/", "This Gemini capsule's homepage", "index"),
("/contact", "Many ways to contact Fuwn", "contact"),