1
0
mirror of https://github.com/actix/actix-website synced 2025-02-19 02:45:13 +01:00

20 lines
470 B
Rust
Raw Normal View History

2018-05-24 10:13:55 -07:00
// <pred>
2018-07-21 05:21:41 -07:00
use actix_web::{http, server::Request, pred::Predicate, App, HttpResponse};
2018-05-24 10:13:55 -07:00
struct ContentTypeHeader;
impl<S: 'static> Predicate<S> for ContentTypeHeader {
2018-07-21 05:21:41 -07:00
fn check(&self, req: &Request, state: &S) -> bool {
2018-05-24 10:13:55 -07:00
req.headers().contains_key(http::header::CONTENT_TYPE)
}
}
fn main() {
App::new().resource("/index.html", |r| {
r.route()
.filter(ContentTypeHeader)
.f(|_| HttpResponse::Ok())
});
}
// </pred>