Struct actix_web::middleware::Condition [−][src]
pub struct Condition<T> { /* fields omitted */ }
Expand description
Middleware
for conditionally enables another middleware.
The controlled middleware must not change the Service
interfaces.
This means you cannot control such middlewares like Logger
or Compress
.
Usage
use actix_web::middleware::{Condition, NormalizePath};
use actix_web::App;
let enable_normalize = std::env::var("NORMALIZE_PATH") == Ok("true".into());
let app = App::new()
.wrap(Condition::new(enable_normalize, NormalizePath::default()));
Implementations
Trait Implementations
The TransformService
value created by this factory
type Future = LocalBoxFuture<'static, Result<Self::Transform, Self::InitError>>
type Future = LocalBoxFuture<'static, Result<Self::Transform, Self::InitError>>
The future response value.
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<T> RefUnwindSafe for Condition<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Condition<T> where
T: UnwindSafe,
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