Skip to content

Commit

Permalink
docs: update router::route multiple methods docs (#2051)
Browse files Browse the repository at this point in the history
Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
  • Loading branch information
mohad12211 and davidpdrsn committed Jun 22, 2023
1 parent c26dcd9 commit 652d65a
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion axum/src/docs/routing/route.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ the path `/foo/bar/baz` the value of `rest` will be `bar/baz`.

# 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:

```rust
Expand All @@ -80,6 +80,23 @@ async fn delete_root() {}
# 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

```rust
Expand Down

0 comments on commit 652d65a

Please sign in to comment.