Skip to content

Commit

Permalink
feat: update Rust template (netlify#6314)
Browse files Browse the repository at this point in the history
The handler_fn function was deprecated in 0.5.0 of the lambda_runtime in favour of the service_fn.
  • Loading branch information
ericapisani authored Jan 12, 2024
1 parent 4f3432d commit 8b3bdf1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/functions-templates/rust/hello-world/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
use aws_lambda_events::event::apigw::{ApiGatewayProxyRequest, ApiGatewayProxyResponse};
use aws_lambda_events::encodings::Body;
use http::header::HeaderMap;
use lambda_runtime::{handler_fn, Context, Error};
use lambda_runtime::{service_fn, Error, LambdaEvent};
use log::LevelFilter;
use simple_logger::SimpleLogger;

#[tokio::main]
async fn main() -> Result<(), Error> {
SimpleLogger::new().with_utc_timestamps().with_level(LevelFilter::Info).init().unwrap();

let func = handler_fn(my_handler);
let func = service_fn(my_handler);
lambda_runtime::run(func).await?;
Ok(())
}

pub(crate) async fn my_handler(event: ApiGatewayProxyRequest, _ctx: Context) -> Result<ApiGatewayProxyResponse, Error> {
let path = event.path.unwrap();
pub(crate) async fn my_handler(event: LambdaEvent<ApiGatewayProxyRequest>) -> Result<ApiGatewayProxyResponse, Error> {
let path = event.payload.path.unwrap();

let resp = ApiGatewayProxyResponse {
status_code: 200,
Expand Down

0 comments on commit 8b3bdf1

Please sign in to comment.