MCPcopy Index your code
hub / github.com/aws/aws-lambda-rust-runtime / main

Function main

examples/http-cors/src/main.rs:7–23  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5
6#[tokio::main]
7async fn main() -> Result<(), Error> {
8 // required to enable CloudWatch error logging by the runtime
9 tracing::init_default_subscriber();
10
11 // Define a layer to inject CORS headers
12 let cors_layer = CorsLayer::new()
13 .allow_methods(vec![Method::GET, Method::POST])
14 .allow_origin(Any);
15
16 let handler = ServiceBuilder::new()
17 // Add the CORS layer to the service
18 .layer(cors_layer)
19 .service(service_fn(func));
20
21 lambda_http::run(handler).await?;
22 Ok(())
23}
24
25async fn func(event: Request) -> Result<Response<Body>, Error> {
26 Ok(

Callers

nothing calls this directly

Calls 3

init_default_subscriberFunction · 0.85
runFunction · 0.50
layerMethod · 0.45

Tested by

no test coverage detected