Skip to content

Commit

Permalink
Add allow_methods to CorsLayer too.
Browse files Browse the repository at this point in the history
  • Loading branch information
emmiegit committed Aug 2, 2023
1 parent d02ae0f commit fef9122
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ edition = "2021"
aws-config = "0.55"
aws-sdk-dynamodb = "0.28"
color-backtrace = "0.5"
http = "0.2"
maplit = "1"
once_cell = "1"
lambda_http = "0.8"
Expand Down
8 changes: 5 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ mod build {
}

use self::handlers::*;
use http::method::Method;
use lambda_http::{
self, service_fn, tower::ServiceBuilder, Body, Error, Request, Response,
self, http::Method, service_fn, tower::ServiceBuilder, Body, Error, Request, Response,
};
use tower_http::cors::{self, CorsLayer};

Expand Down Expand Up @@ -88,7 +87,10 @@ async fn main() -> Result<(), Error> {
.without_time() // disabling time, because CloudWatch adds the ingestion time
.init();

let cors = CorsLayer::new().allow_origin(cors::Any);
let cors = CorsLayer::new()
.allow_methods([Method::GET, Method::PUT])
.allow_origin(cors::Any);

let handler = ServiceBuilder::new()
.layer(cors)
.service(service_fn(function_handler));
Expand Down

0 comments on commit fef9122

Please sign in to comment.