Skip to main content

Module router

Module router 

Source
Expand description

Routing and binding, transport-neutral: a request in, a response out.

The router names no surface. It asks super::surfaces::Served — the web topology this process resolved, narrowed to what it can answer — who owns a path, and dispatches to what that surface bound. A route under /api/v1/ is a capability with an HTTP exposure; /, /openapi.json, /swagger, /cockpit and /mcp are routes the executable answers itself; /docs/ and every generated report are directories a producer wrote. All of them are declared once, in crate::web::discover, and reach the router, the home page, the web.surfaces capability and the publication from there.

Structs§

ErrorBody
The body of every error response.
ErrorDetail
What went wrong, as the HTTP projection names it.
Request
A request as the router sees it: method, path without query, decoded query pairs, headers, and the body.
Response
A response as the router produces it; the server adds the wire.
Router
Routes requests to the surfaces this process serves. Cheap to clone: every worker thread holds one, and the resolution behind it is shared.
ServedRef
The surfaces a router serves, held for as long as its reader needs them.

Enums§

Body
What a response carries. Text for everything this projection computes; bytes for a file it serves from disk, which is not always UTF-8 and must not be repaired into it.

Functions§

percent_decode
%XX and + decoding; a malformed escape is kept as it is.
percent_encode
Percent-encode everything but the unreserved characters of RFC 3986.
prefers_html
Does this request come from something that would rather have a page than a document? Only an explicit text/html in Accept counts: a client that sends none, or */*, gets the JSON index, which is what every existing caller does.