match `/x/a`, `/x/a/`, etc. Wildcard captures can also be extracted using [`Path`](crate::extract::Path): ```rust use axum::{ Router, routing::get, extract::Path, }; let app: Router = Router::new().route("/{*key}", get(handler)); async fn handler(Path(path): Path) -> String { path } ``` Note that the leading slash is not included, i.e. for the route `/foo/{*rest}` and 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 can add all handlers at the same time: ```rust use axum::{Router, routing::{get, delete}, extract::Path}; let app = Router::new().route( "/", get(get_root).post(post_root).delete(delete_root), ); async fn get_root() {} async fn post_root() {} 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 use axum::{Router, routing::{get, delete}, extract::Path}; let app = Router::new() .route("/", get(root)) .route("/users", get(list_users).post(create_user)) .route("/users/{id}", get(show_user)) .route("/api/{version}/users/{id}/action", delete(do_users_action)) .route("/assets/{*path}", get(serve_asset)); async fn root() {} async fn list_users() {} async fn create_user() {} async fn show_user(Path(id): Path) {} async fn do_users_action(Path((version, id)): Path<(String, u64)>) {} async fn serve_asset(Path(path): Path) {} # let _: Router = app; ``` # Panics Panics if the route overlaps with another route: ```rust,should_panic use axum::{routing::get, Router}; let app = Router::new() .route("/", get(|| async {})) .route("/", get(|| async {})); # let _: Router = app; ``` The static route `/foo` and the dynamic route `/{key}` are not considered to overlap and `/foo` will take precedence. Also panics if `path` is empty.