mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-28 00:00:20 +02:00
Add RouteDsl::or to combine routes (#108)
With this you'll be able to do:
```rust
let one = route("/foo", get(|| async { "foo" }))
.route("/bar", get(|| async { "bar" }));
let two = route("/baz", get(|| async { "baz" }));
let app = one.or(two);
```
Fixes https://github.com/tokio-rs/axum/issues/101
This commit is contained in:
@@ -125,6 +125,8 @@
|
||||
//! Routes can also be dynamic like `/users/:id`. See [extractors](#extractors)
|
||||
//! for more details.
|
||||
//!
|
||||
//! You can also define routes separately and merge them with [`RoutingDsl::or`].
|
||||
//!
|
||||
//! ## Precedence
|
||||
//!
|
||||
//! Note that routes are matched _bottom to top_ so routes that should have
|
||||
@@ -662,6 +664,7 @@
|
||||
//! [`IntoResponse`]: crate::response::IntoResponse
|
||||
//! [`Timeout`]: tower::timeout::Timeout
|
||||
//! [examples]: https://github.com/tokio-rs/axum/tree/main/examples
|
||||
//! [`RoutingDsl::or`]: crate::routing::RoutingDsl::or
|
||||
//! [`axum::Server`]: hyper::server::Server
|
||||
|
||||
#![warn(
|
||||
|
||||
Reference in New Issue
Block a user