Expand description
Route resolution helpers — matching a request path + verb against a
controller’s &[RouteDef] and extracting the path/query/body parameters.
Used by the #[controller] macro’s generated dispatch; exposed for tools
and tests that need to resolve routes directly.
Functions§
- covering_
family - Which of
prefixescoversmount— by the same rule thefamiliesblock ofapp_routes!applies at compile time, so a boot-time check written against this cannot disagree with the compile-time one: segment-aligned ("api"covers"api/things", never"apiary"), the longest covering prefix wins (so"api/auth"carves its subtree out of"api"), a trailing*reads as the prefix before it, and the root (""or"*") covers every mount. Returns the winning prefix as it was given, so the caller can look it up in its own table. On two prefixes that normalise identically, the later one wins, as in the macro. - family_
segments - The segments of a mount path or family prefix, normalised exactly as
RouterBuilder::add_routeand thefamiliesblock ofapp_routes!normalise them: surrounding slashes trimmed, empty segments dropped, a trailing*(the catch-all sugar) removed — so"api/*","/api/"and"api"are the same prefix, and""/"*"is the root. - match_
pattern - Match a route pattern against an action path. Returns extracted path parameters if matched.
- param_
is_ required - Whether an absent value for
parammakes the request a400. - resolve
- Main route resolution function. Tries each route in declaration order and returns the first whose path pattern and verb both match, along with its extracted parameters.