Struct actix_web::middleware::Condition
source · [−]pub struct Condition<T> { /* private fields */ }
Expand description
Middleware for conditionally enabling other middleware.
The controlled middleware must not change the Service
interfaces. This means you cannot
control such middlewares like Logger
or Compress
directly. See the Compat
middleware for a workaround.
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
sourceimpl<S, T, Req> Transform<S, Req> for Condition<T> where
S: Service<Req> + 'static,
T: Transform<S, Req, Response = S::Response, Error = S::Error>,
T::Future: 'static,
T::InitError: 'static,
T::Transform: 'static,
impl<S, T, Req> Transform<S, Req> for Condition<T> where
S: Service<Req> + 'static,
T: Transform<S, Req, Response = S::Response, Error = S::Error>,
T::Future: 'static,
T::InitError: 'static,
T::Transform: 'static,
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.
sourcefn new_transform(&self, service: S) -> Self::Future
fn new_transform(&self, service: S) -> Self::Future
Creates and returns a new Transform component, asynchronously
Auto Trait Implementations
impl<T> RefUnwindSafe for Condition<T> where
T: RefUnwindSafe,
impl<T> Send for Condition<T> where
T: Send,
impl<T> Sync for Condition<T> where
T: Sync,
impl<T> Unpin for Condition<T> where
T: Unpin,
impl<T> UnwindSafe for Condition<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more