From: Ian Jackson Date: Mon, 28 Mar 2022 00:56:06 +0000 (+0100) Subject: resource leaf routing: Document why we're leaving it order-sensitive X-Git-Tag: otter-1.0.0~90 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=bbd03bf415a9d2bcd8261583e37434ecbe4131ca;p=otter.git resource leaf routing: Document why we're leaving it order-sensitive Signed-off-by: Ian Jackson --- diff --git a/TODO b/TODO index 76fc57e8..91431989 100644 --- a/TODO +++ b/TODO @@ -2,4 +2,3 @@ TODOs in diff content-type for download bundles http2 HEAD requests fix listen -fix that /_/updates vs /_/ involves ordering diff --git a/daemon/main.rs b/daemon/main.rs index d19f0a28..4cffdb28 100644 --- a/daemon/main.rs +++ b/daemon/main.rs @@ -296,6 +296,15 @@ async fn updates_route(query: Query) -> impl Responder { .streaming(content) } +// Actix dispatches to the first matching URL pattern in the list of +// routes, and does not try another one even if this route says 404. +// This pattern is quite general, so it has to come last. +// +// An alternative would be to use a Guard. But the guard doesn't get +// to give information directly to the route function. We would have +// to use the GuardContext to thread the CheckedResource through the +// Extension type map. It's easier just to make sure this URL pattern +// is last in the list. #[route("/_/{leaf}", method="GET", method="HEAD")] #[throws(io::Error)] async fn resource(leaf: Path>) -> impl Responder { @@ -496,9 +505,9 @@ async fn main() -> Result<(),StartupError> { loading_p, bundle_route, updates_route, - resource, session::routes(), api::routes(), + resource, // Must come after more specific URL paths ]) .app_data(json_config) .app_data(templates.clone())