chiark / gitweb /
resource leaf routing: Document why we're leaving it order-sensitive
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 28 Mar 2022 00:56:06 +0000 (01:56 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 28 Mar 2022 00:56:06 +0000 (01:56 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
TODO
daemon/main.rs

diff --git a/TODO b/TODO
index 76fc57e893836fca97c2d86fd51e950c2ed46161..914319892db770cbe7cc0ff533941d59b4531518 100644 (file)
--- 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 /_/<leaf> involves ordering
index d19f0a289a39abe7af524c2e32df9851046dfde6..4cffdb28a322d8db886a438780c3f717c64ebae9 100644 (file)
@@ -296,6 +296,15 @@ async fn updates_route(query: Query<UpdatesParams>) -> 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<Parse<CheckedResourceLeaf>>) -> 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())