mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-30 00:00:32 +02:00
fix doc tests
This commit is contained in:
@@ -88,7 +88,7 @@ let serve_dir_service = get_service(ServeDir::new("public"))
|
||||
)
|
||||
});
|
||||
|
||||
let app = Router::new().nest("/public", serve_dir_service);
|
||||
let app = Router::new().nest_service("/public", serve_dir_service);
|
||||
# async {
|
||||
# axum::Server::bind(&"".parse().unwrap()).serve(app.into_make_service()).await.unwrap();
|
||||
# };
|
||||
@@ -107,7 +107,7 @@ let app = Router::new()
|
||||
.route("/foo/*rest", get(|uri: Uri| async {
|
||||
// `uri` will contain `/foo`
|
||||
}))
|
||||
.nest("/bar", get(|uri: Uri| async {
|
||||
.nest_service("/bar", get(|uri: Uri| async {
|
||||
// `uri` will _not_ contain `/bar`
|
||||
}));
|
||||
# async {
|
||||
|
||||
@@ -184,22 +184,6 @@ let app = Router::new()
|
||||
The static route `/foo` and the dynamic route `/:key` are not considered to
|
||||
overlap and `/foo` will take precedence.
|
||||
|
||||
Take care when using [`Router::nest`] as it behaves like a wildcard route.
|
||||
Therefore this setup panics:
|
||||
|
||||
```rust,should_panic
|
||||
use axum::{routing::get, Router};
|
||||
|
||||
let app = Router::new()
|
||||
// this is similar to `/api/*`
|
||||
.nest("/api", get(|| async {}))
|
||||
// which overlaps with this route
|
||||
.route("/api/users", get(|| async {}));
|
||||
# async {
|
||||
# axum::Server::bind(&"".parse().unwrap()).serve(app.into_make_service()).await.unwrap();
|
||||
# };
|
||||
```
|
||||
|
||||
Also panics if `path` is empty.
|
||||
|
||||
## Nesting
|
||||
|
||||
@@ -414,7 +414,7 @@ nested_route_test!(nest_3, nest = "", route = "/a/", expected = "/a/");
|
||||
nested_route_test!(nest_4, nest = "/", route = "/", expected = "/");
|
||||
nested_route_test!(nest_5, nest = "/", route = "/a", expected = "/a");
|
||||
nested_route_test!(nest_6, nest = "/", route = "/a/", expected = "/a/");
|
||||
nested_route_test!(nest_7, nest = "/a", route = "/", expected = "/a",);
|
||||
nested_route_test!(nest_7, nest = "/a/", route = "/", expected = "/a");
|
||||
nested_route_test!(nest_8, nest = "/a", route = "/a", expected = "/a/a");
|
||||
nested_route_test!(nest_9, nest = "/a", route = "/a/", expected = "/a/a/");
|
||||
nested_route_test!(nest_11, nest = "/a/", route = "/", expected = "/a/");
|
||||
|
||||
Reference in New Issue
Block a user