utils: Allow zero templates and routes

This commit is contained in:
Steffo 2024-12-18 16:07:18 +01:00
parent 72f12b6de7
commit e2687011eb
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0

View file

@ -29,10 +29,10 @@ macro_rules! web_server {
( (
on: $socket_addr:expr, on: $socket_addr:expr,
templates: [ templates: [
$( $template_path:literal ),+ $( $template_path:literal ),*
], ],
routes: { routes: {
$( $path:literal => $route:expr ),+ $( $path:literal => $route:expr ),*
} }
) => { ) => {
$crate::init::init_logging(); $crate::init::init_logging();
@ -40,11 +40,11 @@ macro_rules! web_server {
let mut mj = $crate::init::init_minijinja(); let mut mj = $crate::init::init_minijinja();
$( $(
$crate::add_minijinja_template!(mj, $template_path); $crate::add_minijinja_template!(mj, $template_path);
)+ )*
let router = $crate::init::init_router(mj); let router = $crate::init::init_router(mj);
$( $(
$crate::add_axum_route!(router, $path, $route); $crate::add_axum_route!(router, $path, $route);
)+ )*
$crate::run::run_server(listener, router).await $crate::run::run_server(listener, router).await
}; };
} }