mirror of
https://github.com/actix/actix-website
synced 2025-01-23 00:25:55 +01:00
20 lines
594 B
Rust
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>
|