Function actix_web::guard::Header

source ·
pub fn Header(name: &'static str, value: &'static str) -> impl Guard
Expand description

Creates a guard that matches if request contains given header name and value.

§Examples

The handler below will be called when the request contains an x-guarded header with value equal to secret.

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

web::route()
    .guard(guard::Header("x-guarded", "secret"))
    .to(|| HttpResponse::Ok());