Skip to content

Commit 3d5565d

Browse files
authored
Replace custom http events with aws_lambda_events (#426)
* Replace custom http events with aws_lambda_events The Alb and ApiGw events in aws_lambda_events are thoroughly tested with multiple payloads that those services generate. Signed-off-by: David Calavera <[email protected]> * Add support for WebSocket requests Signed-off-by: David Calavera <[email protected]> * Don't add the default stage to the request URI ApiGw use $default as an identifier, but it doesn't add it to the URI. Signed-off-by: David Calavera <[email protected]> * Fix formatting Signed-off-by: David Calavera <[email protected]> * Fix examples Signed-off-by: David Calavera <[email protected]> * Replace custom response structs with aws_lambda_events Signed-off-by: David Calavera <[email protected]> * Fix example Signed-off-by: David Calavera <[email protected]>
1 parent e1797cc commit 3d5565d

File tree

12 files changed

+357
-1321
lines changed

12 files changed

+357
-1321
lines changed

lambda-http/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ travis-ci = { repository = "awslabs/aws-lambda-rust-runtime" }
1717
maintenance = { status = "actively-developed" }
1818

1919
[dependencies]
20+
aws_lambda_events = { version = "0.6", default-features = false, features = ["alb", "apigw"]}
2021
base64 = "0.13.0"
2122
bytes = "1"
2223
http = "0.2"
@@ -25,6 +26,7 @@ lambda_runtime = { path = "../lambda-runtime", version = "0.5" }
2526
serde = { version = "^1", features = ["derive"] }
2627
serde_json = "^1"
2728
serde_urlencoded = "0.7.0"
29+
query_map = { version = "0.4", features = ["url-query"] }
2830

2931
[dev-dependencies]
3032
log = "^0.4"

lambda-http/examples/hello-cors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async fn main() -> Result<(), Error> {
1919
}
2020

2121
async fn func(event: Request) -> Result<Response<Body>, Error> {
22-
Ok(match event.query_string_parameters().get("first_name") {
22+
Ok(match event.query_string_parameters().first("first_name") {
2323
Some(first_name) => format!("Hello, {}!", first_name).into_response(),
2424
_ => Response::builder()
2525
.status(400)

lambda-http/examples/hello-http.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ async fn main() -> Result<(), Error> {
77
}
88

99
async fn func(event: Request) -> Result<impl IntoResponse, Error> {
10-
Ok(match event.query_string_parameters().get("first_name") {
10+
Ok(match event.query_string_parameters().first("first_name") {
1111
Some(first_name) => format!("Hello, {}!", first_name).into_response(),
1212
_ => Response::builder()
1313
.status(400)

lambda-http/examples/shared-resources-example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async fn main() -> Result<(), Error> {
2020

2121
// Define a closure here that makes use of the shared client.
2222
let handler_func_closure = move |event: Request| async move {
23-
Ok(match event.query_string_parameters().get("first_name") {
23+
Ok(match event.query_string_parameters().first("first_name") {
2424
Some(first_name) => shared_client_ref
2525
.response(event.lambda_context().request_id, first_name)
2626
.into_response(),

lambda-http/src/body.rs

Lines changed: 0 additions & 295 deletions
This file was deleted.

0 commit comments

Comments
 (0)