Struct actix_web::middleware::Compress [−][src]
pub struct Compress(_);Expand description
Middleware for compressing response body.
Use BodyEncoding trait for overriding response compression.
To disable compression set encoding to ContentEncoding::Identity value.
use actix_web::{web, middleware, App, HttpResponse};
fn main() {
let app = App::new()
.wrap(middleware::Compress::default())
.service(
web::resource("/test")
.route(web::get().to(|| HttpResponse::Ok()))
.route(web::head().to(|| HttpResponse::MethodNotAllowed()))
);
}Implementations
Create new Compress middleware with default encoding.
Trait Implementations
impl<S, B> Transform<S> for Compress where
B: MessageBody,
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
impl<S, B> Transform<S> for Compress where
B: MessageBody,
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
type Request = ServiceRequest
type Request = ServiceRequest
Requests handled by the service.
type Response = ServiceResponse<Encoder<B>>
type Response = ServiceResponse<Encoder<B>>
Responses given by the service.
type Transform = CompressMiddleware<S>
type Transform = CompressMiddleware<S>
The TransformService value created by this factory
Creates and returns a new Transform component, asynchronously
fn map_init_err<F, E>(self, f: F) -> TransformMapInitErr<Self, S, F, E> where
F: Fn(Self::InitError) -> E + Clone,
fn map_init_err<F, E>(self, f: F) -> TransformMapInitErr<Self, S, F, E> where
F: Fn(Self::InitError) -> E + Clone,
Map this transforms’s factory error to a different error, returning a new transform service factory. Read more
Auto Trait Implementations
impl RefUnwindSafe for Compress
impl UnwindSafe for Compress
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span, returning an
Instrumented wrapper. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more
