Skip to content

Commit

Permalink
Clarify some subtleties of routing (#2896)
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaJewson committed Sep 22, 2024
1 parent 2fe4351 commit 068c9a3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion axum/src/docs/routing/fallback.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions axum/src/docs/routing/nest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 068c9a3

Please sign in to comment.