macro_rules! declared_routes {
($(#[$attr:meta])* $vis:vis fn $name:ident, $table:ident; $($method:ident $path:expr $(, $policy:ident)? => $handler:expr $(, layer($layer:expr))? $(, route_layer($route_layer:expr))?;)+) => { ... };
(@on GET) => { ... };
(@on POST) => { ... };
(@on PUT) => { ... };
(@on PATCH) => { ... };
(@on DELETE) => { ... };
(@on ANY) => { ... };
(@policy GET) => { ... };
(@policy ANY) => { ... };
(@policy POST $policy:ident) => { ... };
(@policy PUT $policy:ident) => { ... };
(@policy PATCH $policy:ident) => { ... };
(@policy DELETE $policy:ident) => { ... };
}Expand description
Declares a group of routes: the function that builds their router, and their table.
ⓘ
declared_routes! {
/// What the group is.
pub(super) fn vault_routes, VAULT_ROUTES;
GET "/api/v1/vault" => handlers::list;
POST "/api/v1/vault/show", Never => handlers::show;
}A read (GET) takes no policy; a write (POST, PUT, PATCH, DELETE) takes one of
Always, Plumbing, Handler and Never, and does not compile without it. ANY is for a
route that passes every method on to something else (the model gateway); it takes no policy,
because the record asks by the method of the call and so never finds an ANY line. Two lines may
name the same path with different methods. The path is a literal or a constant. A line may end
with , layer(..) or , route_layer(..) for a layer on that one route’s handler. What a group
shares (a layer over all of it, another group merged in) is written in a function that calls
the declared one.