stdlib::http::router
defined in C:\Users\bye45\.glide\bin/src/stdlib/http/router.glide
One piece of a compiled route pattern.
One piece of a compiled route pattern.
kind is RS_LITERAL (the segment text must match), RS_PARAM (any one segment, captured under text), or RS_WILDCARD (the rest of the path, captured under text). Wildcard segments can only appear last; later segments after a * are ignored.
One row of the routing table.
local_mws is the per-route middleware chain — populated when the route was mounted via Router::scope(prefix, sub). Parent middleware runs first, then local_mws (in registration order), then the handler.
Wildcard sentinel for Router::any. dispatch matches any verb when route.method equals this exact string.
HTTP method router. Stores routes in declaration order; the first match wins. Middleware in mw runs before the matched handler in registration order. A separate "not found" handler covers no-match dispatches; defaults to a plain 404 with body "not found".
Per-dispatch chain context. Threaded through every middleware so each can call chain_next(c) to advance to the next middleware (or the route handler when the middleware list is exhausted). Middleware that returns without calling chain_next short- circuits the chain — the rest of the middleware AND the route handler are skipped.
Advance the middleware chain. The first call from inside middleware N runs middleware N+1; once the list is exhausted the route handler runs.
fn logger(req: *HttpRequest, c: *Chain) -> HttpResponse {
println!("[", req.method, "] ", req.path);
let resp: HttpResponse = chain_next(c);
println!(" -> ", resp.status);
return resp;
}