macro_rules! routes {
() => { ... };
($($($segment:ident)::+),+ $(,)?) => { ... };
}Expand description
Collect route handlers into an axum::Router<AroState>.
Takes a list of handler function names and chains their generated
__aro_register_<fn> functions into a single Router. Non-empty invocations
produce a Router<AroState>, making handlers compatible with both stateless
handlers and handlers using Dep<T> extractors.
ยงExamples
โ
use aro_web::routes;
// Stateless handlers
let router = routes![hello, get_user, create_user];
App::new().routes_with_state(router).build();
// Stateful handlers using Dep<T>
let router = routes![handler_with_dep, stateless_handler];
App::new()
.register::<dyn MyService>(service)
.routes_with_state(router)
.build();Module-qualified paths are supported:
โ
let router = routes![users::get_user, users::create_user];An empty invocation returns an empty Router<()> for composition with
stateless routes; use App::routes_with_state only
when the router contains handlers:
โ
let router = routes![];