Struct actix_web::middleware::Condition [−][src]
pub struct Condition<T> { /* fields omitted */ }
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
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