1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 22:49:21 +02:00

Impl BodyEncoding for Response (#740)

This commit is contained in:
Douman
2019-03-30 02:29:11 +03:00
committed by Nikolay Kim
parent c126713f40
commit 00526f60dc
3 changed files with 44 additions and 1 deletions

View File

@ -6,7 +6,7 @@ use std::str::FromStr;
use actix_http::body::MessageBody;
use actix_http::encoding::Encoder;
use actix_http::http::header::{ContentEncoding, ACCEPT_ENCODING};
use actix_http::ResponseBuilder;
use actix_http::{Response, ResponseBuilder};
use actix_service::{Service, Transform};
use futures::future::{ok, FutureResult};
use futures::{Async, Future, Poll};
@ -27,6 +27,13 @@ impl BodyEncoding for ResponseBuilder {
}
}
impl<B> BodyEncoding for Response<B> {
fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self {
self.extensions_mut().insert(Enc(encoding));
self
}
}
#[derive(Debug, Clone)]
/// `Middleware` for compressing response body.
///