mirror of
https://github.com/tokio-rs/axum.git
synced 2025-10-02 15:24:54 +00:00
docs: update router::route multiple methods docs (#2051)
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
This commit is contained in:
parent
c26dcd90b3
commit
652d65aabc
@ -61,7 +61,7 @@ the path `/foo/bar/baz` the value of `rest` will be `bar/baz`.
|
|||||||
|
|
||||||
# Accepting multiple methods
|
# Accepting multiple methods
|
||||||
|
|
||||||
To accept multiple methods for the same route you must add all handlers at the
|
To accept multiple methods for the same route you can add all handlers at the
|
||||||
same time:
|
same time:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
@ -80,6 +80,23 @@ async fn delete_root() {}
|
|||||||
# let _: Router = app;
|
# let _: Router = app;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or you can add them one by one:
|
||||||
|
|
||||||
|
```rust
|
||||||
|
# use axum::Router;
|
||||||
|
# use axum::routing::{get, post, delete};
|
||||||
|
#
|
||||||
|
let app = Router::new()
|
||||||
|
.route("/", get(get_root))
|
||||||
|
.route("/", post(post_root))
|
||||||
|
.route("/", delete(delete_root));
|
||||||
|
#
|
||||||
|
# let _: Router = app;
|
||||||
|
# async fn get_root() {}
|
||||||
|
# async fn post_root() {}
|
||||||
|
# async fn delete_root() {}
|
||||||
|
```
|
||||||
|
|
||||||
# More examples
|
# More examples
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
Loading…
x
Reference in New Issue
Block a user