From c573f1ea806a44b89b3e4b84e02b68f838f1279b Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 20 Apr 2022 00:18:23 -0700 Subject: refactor(macros): batch_mount files --- src/macros.rs | 9 +++++++-- src/main.rs | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 13 deletions(-) (limited to 'src') 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> { }); 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"), -- cgit v1.2.3