From 652d65aabce95d508bbf1ee7bf05053c83f0d230 Mon Sep 17 00:00:00 2001 From: mohad12211 <51754973+mohad12211@users.noreply.github.com> Date: Fri, 23 Jun 2023 00:36:37 +0300 Subject: [PATCH] docs: update router::route multiple methods docs (#2051) Co-authored-by: David Pedersen --- axum/src/docs/routing/route.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/axum/src/docs/routing/route.md b/axum/src/docs/routing/route.md index 394ae59b..a4491897 100644 --- a/axum/src/docs/routing/route.md +++ b/axum/src/docs/routing/route.md @@ -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 @@ -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