Struct actix_web::middleware::DefaultHeaders
source · [−]pub struct DefaultHeaders { /* private fields */ }
Expand description
Middleware for setting default response headers.
Headers with the same key that are already set in a response will not be overwritten.
Examples
use actix_web::{web, http, middleware, App, HttpResponse};
let app = App::new()
.wrap(middleware::DefaultHeaders::new().add(("X-Version", "0.2")))
.service(
web::resource("/test")
.route(web::get().to(|| HttpResponse::Ok()))
.route(web::method(http::Method::HEAD).to(|| HttpResponse::MethodNotAllowed()))
);
Implementations
Constructs an empty DefaultHeaders
middleware.
Adds a default Content-Type header if response does not contain one.
Default is application/octet-stream
.
Trait Implementations
Returns the “default value” for a type. Read more
impl<S, B> Transform<S, ServiceRequest> for DefaultHeaders where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
impl<S, B> Transform<S, ServiceRequest> for DefaultHeaders where
S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = Error>,
S::Future: 'static,
type Response = ServiceResponse<B>
type Response = ServiceResponse<B>
Responses produced by the service.
type Transform = DefaultHeadersMiddleware<S>
type Transform = DefaultHeadersMiddleware<S>
The TransformService
value created by this factory
Creates and returns a new Transform component, asynchronously
Auto Trait Implementations
impl RefUnwindSafe for DefaultHeaders
impl !Send for DefaultHeaders
impl !Sync for DefaultHeaders
impl Unpin for DefaultHeaders
impl UnwindSafe for DefaultHeaders
Blanket Implementations
Mutably borrows from an owned value. 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