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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user