mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-07 00:00:12 +02:00
+4
-10
@@ -239,8 +239,8 @@
|
||||
//! # };
|
||||
//! ```
|
||||
//!
|
||||
//! [`extract::UrlParams`] can be used to extract params from a dynamic URL. It
|
||||
//! is compatible with any type that implements [`std::str::FromStr`], such as
|
||||
//! [`extract::Path`] can be used to extract params from a dynamic URL. It
|
||||
//! is compatible with any type that implements [`serde::Deserialize`], such as
|
||||
//! [`Uuid`]:
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
@@ -249,9 +249,7 @@
|
||||
//!
|
||||
//! let app = route("/users/:id", post(create_user));
|
||||
//!
|
||||
//! async fn create_user(params: extract::UrlParams<(Uuid,)>) {
|
||||
//! let user_id: Uuid = (params.0).0;
|
||||
//!
|
||||
//! async fn create_user(extract::Path(user_id): extract::Path<Uuid>) {
|
||||
//! // ...
|
||||
//! }
|
||||
//! # async {
|
||||
@@ -259,9 +257,6 @@
|
||||
//! # };
|
||||
//! ```
|
||||
//!
|
||||
//! There is also [`UrlParamsMap`](extract::UrlParamsMap) which provide a map
|
||||
//! like API for extracting URL params.
|
||||
//!
|
||||
//! You can also apply multiple extractors:
|
||||
//!
|
||||
//! ```rust,no_run
|
||||
@@ -284,10 +279,9 @@
|
||||
//! }
|
||||
//!
|
||||
//! async fn get_user_things(
|
||||
//! params: extract::UrlParams<(Uuid,)>,
|
||||
//! extract::Path(user_id): extract::Path<Uuid>,
|
||||
//! pagination: Option<extract::Query<Pagination>>,
|
||||
//! ) {
|
||||
//! let user_id: Uuid = (params.0).0;
|
||||
//! let pagination: Pagination = pagination.unwrap_or_default().0;
|
||||
//!
|
||||
//! // ...
|
||||
|
||||
Reference in New Issue
Block a user