Function actix_web::pred::Host

source ·
pub fn Host<S: 'static, H: AsRef<str>>(host: H) -> HostPredicate<S>
Expand description

Return predicate that matches if request contains specified Host name.

use actix_web::{pred, App, HttpResponse};

fn main() {
    App::new().resource("/index.html", |r| {
        r.route()
            .filter(pred::Host("www.rust-lang.org"))
            .f(|_| HttpResponse::MethodNotAllowed())
    });
}