1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-08-02 18:55:05 +00:00

add encoding section

This commit is contained in:
Nikolay Kim 2017-12-03 18:58:15 -08:00
parent 319e9bbd05
commit 57c53bd2a0

View file

@ -13,6 +13,19 @@ Following encodings are supported:
If request headers contains `Content-Encoding` header, request payload get decompressed
according to header value. Multiple codecs are not supported, i.e: `Content-Encoding: br, gzip`.
Response payload get compressed based on `content_encoding` settings.
If `ContentEncoding::Auto` is selected then compression depends on request's
`Accept-Encoding` header. `ContentEncoding::Identity` could be used to disable compression.
If other content encoding is selected the compression is enforced.
```rust,ignore
fn index(req: HttpRequest) -> HttpResponse {
HttpResponse::Ok()
.content_encoding(ContentEncoding::Br)
.body(Body)
}
```
## JSON Response
The `Json` type allows you to respond with well-formed JSON data: simply return a value of