diff --git a/axum/src/docs/routing/route.md b/axum/src/docs/routing/route.md index eefbb21b..fa55f4fa 100644 --- a/axum/src/docs/routing/route.md +++ b/axum/src/docs/routing/route.md @@ -56,7 +56,22 @@ Note that `/*key` doesn't match empty segments. Thus: - `/*key` doesn't match `/` but does match `/a`, `/a/`, etc. - `/x/*key` doesn't match `/x` or `/x/` but does match `/x/a`, `/x/a/`, etc. -Wildcard captures can also be extracted using [`Path`](crate::extract::Path). +Wildcard captures can also be extracted using [`Path`](crate::extract::Path): + +```rust +use axum::{ + Router, + routing::get, + extract::Path, +}; + +let app: Router = Router::new().route("/*key", get(handler)); + +async fn handler(Path(path): Path) -> String { + path +} +``` + Note that the leading slash is not included, i.e. for the route `/foo/*rest` and the path `/foo/bar/baz` the value of `rest` will be `bar/baz`.