From 904ac81e7e754e87e0d64de59a75d38af63efdca Mon Sep 17 00:00:00 2001 From: Fuwn Date: Wed, 20 Apr 2022 00:08:21 -0700 Subject: refactor(macros): crate batch mount file macro --- src/macros.rs | 9 +++++++++ src/main.rs | 42 +++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 21 deletions(-) (limited to 'src') 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> { "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" + ), ); }); -- cgit v1.2.3