mirror of
https://github.com/tokio-rs/axum.git
synced 2024-11-22 07:08:16 +01:00
Update readme
This commit is contained in:
parent
08c10fe58d
commit
d7a0715188
1 changed files with 15 additions and 3 deletions
18
README.md
18
README.md
|
@ -87,8 +87,8 @@ async fn handler(
|
|||
// deserialize query string into a `Pagination`
|
||||
pagination: extract::Query<Pagination>,
|
||||
) -> &'static str {
|
||||
let user: UserPayload = user.into_inner();
|
||||
let pagination: Pagination = pagination.into_inner();
|
||||
let user: UserPayload = user.0;
|
||||
let pagination: Pagination = pagination.0;
|
||||
|
||||
// ...
|
||||
}
|
||||
|
@ -148,12 +148,24 @@ async fn handle(
|
|||
// or get a tuple with each param
|
||||
params: extract::UrlParams<(i32, String)>,
|
||||
) -> &'static str {
|
||||
let (id, name) = params.into_inner();
|
||||
let (id, name) = params.0;
|
||||
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
If you wanna go all out you can even deconstruct the extractor directly in the
|
||||
function signature:
|
||||
|
||||
```rust
|
||||
async fn handle(
|
||||
req: Request<Body>,
|
||||
UrlParams((id, name)): UrlParams<(i32, String)>,
|
||||
) -> &'static str {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
Anything that implements `FromRequest` can work as an extractor where
|
||||
`FromRequest` is an async trait:
|
||||
|
||||
|
|
Loading…
Reference in a new issue