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

Responses produced by the service.

Errors produced by the service.

The TransformService value created by this factory

Errors produced while building a transform service.

The future response value.

Creates and returns a new Transform component, asynchronously

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.