Update readme

This commit is contained in:
David Pedersen 2021-06-01 15:12:22 +02:00
parent 08c10fe58d
commit d7a0715188

View file

@ -87,8 +87,8 @@ async fn handler(
// deserialize query string into a `Pagination` // deserialize query string into a `Pagination`
pagination: extract::Query<Pagination>, pagination: extract::Query<Pagination>,
) -> &'static str { ) -> &'static str {
let user: UserPayload = user.into_inner(); let user: UserPayload = user.0;
let pagination: Pagination = pagination.into_inner(); let pagination: Pagination = pagination.0;
// ... // ...
} }
@ -148,12 +148,24 @@ async fn handle(
// or get a tuple with each param // or get a tuple with each param
params: extract::UrlParams<(i32, String)>, params: extract::UrlParams<(i32, String)>,
) -> &'static str { ) -> &'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 Anything that implements `FromRequest` can work as an extractor where
`FromRequest` is an async trait: `FromRequest` is an async trait: