summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSabrina Jewson <sejewson@gmail.com>2024-09-22 12:32:59 +0100
committerGitHub <noreply@github.com>2024-09-22 13:32:59 +0200
commit068c9a3e96463ef6eb78f68ca7bc1bcc6eb638e7 (patch)
tree8d72000b99b37f7eb3e6f49326c9a4e1f8e26a17
parent2fe435173e158c58c0075386a69f62b24eec131c (diff)
Clarify some subtleties of routing (#2896)
-rw-r--r--axum/src/docs/routing/fallback.md6
-rw-r--r--axum/src/docs/routing/nest.md5
2 files changed, 10 insertions, 1 deletions
diff --git a/axum/src/docs/routing/fallback.md b/axum/src/docs/routing/fallback.md
index 27fb76a5..a864b7a4 100644
--- a/axum/src/docs/routing/fallback.md
+++ b/axum/src/docs/routing/fallback.md
@@ -23,7 +23,11 @@ async fn fallback(uri: Uri) -> (StatusCode, String) {
Fallbacks only apply to routes that aren't matched by anything in the
router. If a handler is matched by a request but returns 404 the
-fallback is not called.
+fallback is not called. Note that this applies to [`MethodRouter`]s too: if the
+request hits a valid path but the [`MethodRouter`] does not have an appropriate
+method handler installed, the fallback is not called (use
+[`MethodRouter::fallback`] for this purpose instead).
+
# Handling all requests without other routes
diff --git a/axum/src/docs/routing/nest.md b/axum/src/docs/routing/nest.md
index 3151729e..845072f0 100644
--- a/axum/src/docs/routing/nest.md
+++ b/axum/src/docs/routing/nest.md
@@ -82,6 +82,11 @@ let app = Router::new()
# let _: Router = app;
```
+Additionally, while the wildcard route `/foo/*rest` will not match the
+paths `/foo` or `/foo/`, a nested router at `/foo` will match the path `/foo`
+(but not `/foo/`), and a nested router at `/foo/` will match the path `/foo/`
+(but not `/foo`).
+
# Fallbacks
If a nested router doesn't have its own fallback then it will inherit the