mirror of
https://github.com/tokio-rs/axum.git
synced 2024-11-26 00:56:27 +01:00
explain that Router::merge
only merges paths and fallback (#2316)
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
This commit is contained in:
parent
0c7ff7c76b
commit
f7a0011ea5
2 changed files with 8 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
Merge two routers into one.
|
Merge the paths and fallbacks of two routers into a single [`Router`].
|
||||||
|
|
||||||
This is useful for breaking apps into smaller pieces and combining them
|
This is useful for breaking apps into smaller pieces and combining them
|
||||||
into one.
|
into one.
|
||||||
|
@ -71,6 +71,11 @@ let app = Router::new()
|
||||||
# let _: axum::Router = app;
|
# let _: axum::Router = app;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Merging routers with fallbacks
|
||||||
|
|
||||||
|
When combining [`Router`]s with this method, the [fallback](Router::fallback) is also merged.
|
||||||
|
However only one of the routers can have a fallback.
|
||||||
|
|
||||||
# Panics
|
# Panics
|
||||||
|
|
||||||
- If two routers that each have a [fallback](Router::fallback) are merged. This
|
- If two routers that each have a [fallback](Router::fallback) are merged. This
|
||||||
|
|
|
@ -135,6 +135,8 @@ async fn layer_and_handle_error() {
|
||||||
|
|
||||||
let res = client.get("/timeout").send().await;
|
let res = client.get("/timeout").send().await;
|
||||||
assert_eq!(res.status(), StatusCode::REQUEST_TIMEOUT);
|
assert_eq!(res.status(), StatusCode::REQUEST_TIMEOUT);
|
||||||
|
let res = client.get("/foo").send().await;
|
||||||
|
assert_eq!(res.status(), StatusCode::OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[crate::test]
|
#[crate::test]
|
||||||
|
|
Loading…
Reference in a new issue