Macro goohttp::impl_route_group
source · macro_rules! impl_route_group { { $group_id:tt { $ ($group:tt); *; } } => { ... }; }
Expand description
Use this macro to create a new group of routes.
To create new routes use the impl_routes macro.
Example
This macro can only be used to nest routes created by the impl_routes macro.
…/mcserver/info/mod.rs
impl_routes! {
info {
get_list, get;
get_log, get
}
}…/mcserver/actions/mod.rs
impl_routes! {
actions {
start, get;
stop, get
}
}…/mcserver/mod.rs
impl_route_groups! {
mcserver { // This must be the name of the module. Otherwise, this module will be useless to other modules that use this macro.
info;
actions;
}
}Once this macro has been expanded, you will get the following code.
mod info;
mod actions;
pub fn mcserver() -> goohttp::axum::Router {
goohttp::axum::Router::new()
.nest("/info", info::info())
.nest("/actions", actions::actions())
}