Restore cors by re-ordering middleware?

Compiler complains about the logger mw preceding the cors mw. Not sure
why. Does it matter?
This commit is contained in:
Jim Crossley 2021-07-02 12:29:17 -04:00
parent 0c56668099
commit 293a8b109e
2 changed files with 2 additions and 0 deletions

View File

@ -7,6 +7,7 @@ edition = "2018"
[dependencies] [dependencies]
cloudevents-sdk = { path = "../..", features = ["cloudevents-actix"] } cloudevents-sdk = { path = "../..", features = ["cloudevents-actix"] }
actix-web = "4.0.0-beta.8" actix-web = "4.0.0-beta.8"
actix-cors = "0.6.0-beta.2"
lazy_static = "1.4.0" lazy_static = "1.4.0"
bytes = "^0.5" bytes = "^0.5"
futures = "^0.3" futures = "^0.3"

View File

@ -29,6 +29,7 @@ async fn main() -> std::io::Result<()> {
HttpServer::new(|| { HttpServer::new(|| {
App::new() App::new()
.wrap(actix_cors::Cors::permissive())
.wrap(actix_web::middleware::Logger::default()) .wrap(actix_web::middleware::Logger::default())
.service(post_event) .service(post_event)
.service(get_event) .service(get_event)