The verb-mode dispatcher. Every URL that resolves to a resource enters here; the ?view= query string then selects which handler actually runs. Living in src/routes/view.rs, it is short by design — every per-verb handler lives in its own sibling file.
endpoint! {
APP.url("/<**path>"),
pub view <HTTP> { dispatch(req).await }
}
This catch-all owns the bare-URL side of the language scheme. The mirror set of /<lang>/<**path> endpoints is emitted by build.rs (see Language system); each generated endpoint installs a LangOverride into req.params and then calls into the same dispatch function. That’s why dispatch is pub — the build-generated prefix endpoints invoke it directly so the bare URL and every /<code>/... URL share one routing table.
dispatch functionpub async fn dispatch(req: &mut HttpReqCtx) -> HttpResponse {
let view_q = req.query("view").unwrap_or_default();
match view_q.as_str() {
"edit" => edit::handle(req).await,
"download" => download::handle(req).await,
"permissions" => permissions::handle(req).await,
_ => { /* default render */ }
}
}
Three verb modes peel off into dedicated handlers:
?view=edit -> Route: edit?view=download -> Route: download?view=permissions -> Route: permissionsAnything else (including the empty query) falls through to the default branch.
The default branch is the read path that renders the resource page itself. It does three things, in order:
crate::req_path(req). For prefix endpoints this strips the /<lang> segment (the EffectivePath stashed in req.params); for the bare endpoint it returns req.path() as-is.guard::probe(req, &path, Role::Write) decides can_edit, and guard::probe(req, &path, Role::Owner) decides can_manage_perms. probe is the non-failing twin of guard::require — it just returns bool so the template can conditionally show the Edit and Permissions buttons.content::render(req, can_edit, can_manage_perms), which loads ctx.json, dispatches by type, and renders the appropriate per-type template.dispatch is pubbuild.rs generates one endpoint! per supported non-default language so each /<code>/<**path> URL gets its own concrete route registration (this is what lets the router match /zh/foo/ distinctly from /foo/). Each generated handler body is essentially LangOverride::install(req, "zh"); dispatch(req).await. Making dispatch public is the seam that keeps the routing logic in one place — verb dispatch, permission probes, and per-type render — even though the endpoint table has N+1 entries.
For the per-type render details that live downstream of the default branch, see Type: board, Type: list, Type: singlemd, Type: mdbook, Type: file, and Type: link.