1
0
mirror of https://github.com/actix/actix-website synced 2025-01-23 00:25:55 +01:00
actix-website/examples/middleware/src/default_headers.rs
2022-02-26 03:56:24 +00:00

20 lines
594 B
Rust

// <default-headers>
use actix_web::{http::Method, middleware, web, App, HttpResponse, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.wrap(middleware::DefaultHeaders::new().add(("X-Version", "0.2")))
.service(
web::resource("/test")
.route(web::get().to(HttpResponse::Ok))
.route(web::method(Method::HEAD).to(HttpResponse::MethodNotAllowed)),
)
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
// </default-headers>