1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 10:27:42 +02:00

add vary header to all handled responses (#224)

This commit is contained in:
Rob Ede
2022-02-07 16:34:01 +00:00
committed by GitHub
parent f9beeecaf6
commit 695800c9bd
6 changed files with 156 additions and 29 deletions

View File

@ -1,12 +1,16 @@
use actix_cors::Cors;
use actix_web::{http::header, web, App, HttpServer};
use actix_web::{http::header, middleware::Logger, web, App, HttpServer};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
log::info!("starting HTTP server at http://localhost:8080");
HttpServer::new(move || {
App::new()
// `permissive` is a wide-open development config
// .wrap(Cors::permissive())
.wrap(
// default settings are overly restrictive to reduce chance of
// misconfiguration leading to security concerns
@ -38,9 +42,11 @@ async fn main() -> std::io::Result<()> {
// set preflight cache TTL
.max_age(3600),
)
.wrap(Logger::default())
.default_service(web::to(|| async { "Hello, cross-origin world!" }))
})
.bind("127.0.0.1:8080")?
.workers(1)
.bind(("127.0.0.1", 8080))?
.run()
.await
}