mirror of
https://github.com/tokio-rs/axum.git
synced 2025-03-08 08:56:24 +01:00
A few more changes
This commit is contained in:
parent
a69ba56ebe
commit
6f5b2708d5
1 changed files with 16 additions and 1 deletions
17
README.md
17
README.md
|
@ -91,6 +91,17 @@ async fn handler(
|
|||
}
|
||||
```
|
||||
|
||||
The inputs can also be optional:
|
||||
|
||||
```rust
|
||||
async fn handler(
|
||||
req: Request<Body>,
|
||||
user: Option<extract::Json<UserPayload>>,
|
||||
) -> Result<&'static str, Error> {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
You can also get the raw response body:
|
||||
|
||||
```rust
|
||||
|
@ -125,7 +136,11 @@ pub trait FromRequest: Sized {
|
|||
}
|
||||
```
|
||||
|
||||
This "extractor" pattern is inspired by Bevy's ECS.
|
||||
This "extractor" pattern is inspired by Bevy's ECS. The idea is that it should
|
||||
be easy to parse pick apart the request without having to repeat yourself a lot
|
||||
or use macros.
|
||||
|
||||
Dynamic routes like `GET /users/:id` is also supported.
|
||||
|
||||
You can also return different response types:
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue