38 lines
780 B
Markdown
38 lines
780 B
Markdown
|
# axum-image
|
||
|
|
||
|
Image extractors for Axum + quick image encoding helpers.
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
The included extractors can be used as any other extractor in Axum:
|
||
|
|
||
|
```rust
|
||
|
use axum_image::extract::Image;
|
||
|
|
||
|
async fn example(img: Image) -> {
|
||
|
// ...
|
||
|
}
|
||
|
```
|
||
|
|
||
|
The `JsonMultipart` extractor works just as the regular `Json` extractor does, just with another field for bytes sent in the request.
|
||
|
|
||
|
```rust
|
||
|
use axum_image::extract::JsonMultipart;
|
||
|
use serde::Deserialize;
|
||
|
|
||
|
#[derive(Deserialize)]
|
||
|
struct JsonBody {
|
||
|
pub field: u32,
|
||
|
}
|
||
|
|
||
|
async fn example(JsonMultipart(byte_parts, req): JsonMultipart<JsonBody>) -> {
|
||
|
println!("field: {}", req.field);
|
||
|
println!("received {} byte parts", byte_parts.len());
|
||
|
// ...
|
||
|
}
|
||
|
```
|
||
|
|
||
|
## License
|
||
|
|
||
|
`axum-image` is licensed under the [AGPL-3.0](./LICENSE).
|