mirror of
https://github.com/tokio-rs/axum.git
synced 2025-10-02 15:24:54 +00:00
A few more changes
This commit is contained in:
parent
a69ba56ebe
commit
6f5b2708d5
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:
|
You can also get the raw response body:
|
||||||
|
|
||||||
```rust
|
```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:
|
You can also return different response types:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user