Struct actix_web::middleware::Condition
source · pub struct Condition<T> { /* private fields */ }
Expand description
Middleware for conditionally enabling other middleware.
Examples
use actix_web::middleware::{Condition, NormalizePath};
use actix_web::App;
let enable_normalize = std::env::var("NORMALIZE_PATH").is_ok();
let app = App::new()
.wrap(Condition::new(enable_normalize, NormalizePath::default()));
Implementations§
Trait Implementations§
source§impl<S, T, Req, BE, BD, Err> Transform<S, Req> for Condition<T>where
S: Service<Req, Response = ServiceResponse<BD>, Error = Err> + 'static,
T: Transform<S, Req, Response = ServiceResponse<BE>, Error = Err>,
T::Future: 'static,
T::InitError: 'static,
T::Transform: 'static,
impl<S, T, Req, BE, BD, Err> Transform<S, Req> for Condition<T>where
S: Service<Req, Response = ServiceResponse<BD>, Error = Err> + 'static,
T: Transform<S, Req, Response = ServiceResponse<BE>, Error = Err>,
T::Future: 'static,
T::InitError: 'static,
T::Transform: 'static,
§type Response = ServiceResponse<EitherBody<BE, BD>>
type Response = ServiceResponse<EitherBody<BE, BD>>
Responses produced by the service.
§type Transform = ConditionMiddleware<<T as Transform<S, Req>>::Transform, S>
type Transform = ConditionMiddleware<<T as Transform<S, Req>>::Transform, S>
The
TransformService
value created by this factory§type InitError = <T as Transform<S, Req>>::InitError
type InitError = <T as Transform<S, Req>>::InitError
Errors produced while building a transform service.
§type Future = Pin<Box<dyn Future<Output = Result<<Condition<T> as Transform<S, Req>>::Transform, <Condition<T> as Transform<S, Req>>::InitError>> + 'static, Global>>
type Future = Pin<Box<dyn Future<Output = Result<<Condition<T> as Transform<S, Req>>::Transform, <Condition<T> as Transform<S, Req>>::InitError>> + 'static, Global>>
The future response value.
source§fn new_transform(&self, service: S) -> Self::Future
fn new_transform(&self, service: S) -> Self::Future
Creates and returns a new Transform component, asynchronously