Function actix_web::guard::All

source ·
pub fn All<F: Guard + 'static>(guard: F) -> AllGuard
Expand description

Creates a guard that matches if all added guards match.

§Examples

The handler below will only be called if the request method is GET and the specified header name and value match exactly.

use actix_web::{guard, web, HttpResponse};

web::route()
    .guard(
        guard::All(guard::Get())
            .and(guard::Header("accept", "text/plain"))
    )
    .to(|| HttpResponse::Ok());