← all modules
module

stdlib::http::router

defined in C:\Users\bye45\.glide\bin/src/stdlib/http/router.glide

One piece of a compiled route pattern.

const const RS_LITERAL: int
const const RS_PARAM: int
const const RS_WILDCARD: int
struct struct RouteSegment

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.

struct struct Route

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.

const const ANY_METHOD: string

Wildcard sentinel for Router::any. dispatch matches any verb when route.method equals this exact string.

struct struct Router

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".

struct struct Chain

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.

fn fn chain_next(c: *Chain) -> HttpResponse

Advance the middleware chain. The first call from inside middleware N runs middleware N+1; once the list is exhausted the route handler runs.

glide
fn logger(req: *HttpRequest, c: *Chain) -> HttpResponse {
    println!("[", req.method, "] ", req.path);
    let resp: HttpResponse = chain_next(c);
    println!("  -> ", resp.status);
    return resp;
}