From a0c281d81944f2b289ba50c740b088a50d8b0cea Mon Sep 17 00:00:00 2001 From: Vassil Kolarov Date: Thu, 13 Jan 2022 18:36:51 +0000 Subject: [PATCH 1/5] added resource field to ApiGateway enum --- .gitignore | 3 ++- lambda-http/src/request.rs | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index bb7ec9b9..07a174b1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ lambda.zip output.json .aws-sam -build \ No newline at end of file +build.history +.history diff --git a/lambda-http/src/request.rs b/lambda-http/src/request.rs index 4b230e51..bb80f8b7 100644 --- a/lambda-http/src/request.rs +++ b/lambda-http/src/request.rs @@ -86,7 +86,9 @@ pub enum LambdaRequest<'a> { body: Option>, #[serde(default)] is_base64_encoded: bool, - request_context: ApiGatewayRequestContext, + request_context: ApiGatewayRequestContext, + #[serde(default, deserialize_with = "nullable_default")] + resource: Option, }, } @@ -436,6 +438,7 @@ impl<'a> From> for http::Request { body, is_base64_encoded, request_context, + resource: _, } => { let builder = http::Request::builder() .method(http_method) From 8e6565089364ee57bc97fd66303b7b91182a4f8d Mon Sep 17 00:00:00 2001 From: Vassil Kolarov Date: Thu, 13 Jan 2022 19:34:51 +0000 Subject: [PATCH 2/5] updated ApiGatewayContext --- lambda-http/src/request.rs | 21 +++++++++++++++++++ .../data/apigw_multi_value_proxy_request.json | 1 + lambda-http/tests/data/apigw_no_host.json | 1 + .../tests/data/apigw_proxy_request.json | 1 + 4 files changed, 24 insertions(+) diff --git a/lambda-http/src/request.rs b/lambda-http/src/request.rs index bb80f8b7..b238fab5 100644 --- a/lambda-http/src/request.rs +++ b/lambda-http/src/request.rs @@ -154,12 +154,32 @@ pub struct ApiGatewayRequestContext { pub account_id: String, /// The identifier that API Gateway assigns to your resource. pub resource_id: String, + /// + #[serde(default, deserialize_with = "nullable_default")] + pub operation_name: Option, /// The deployment stage of the API request (for example, Beta or Prod). pub stage: String, + /// + #[serde(default, deserialize_with = "nullable_default")] + pub domain_name: Option, + /// + #[serde(default, deserialize_with = "nullable_default")] + pub domain_prefix: Option, /// The ID that API Gateway assigns to the API request. pub request_id: String, /// The path to your resource. For example, for the non-proxy request URI of `https://{rest-api-id.execute-api.{region}.amazonaws.com/{stage}/root/child`, The $context.resourcePath value is /root/child. pub resource_path: String, + /// + #[serde(default, deserialize_with = "nullable_default")] + pub protocol: Option, + /// + #[serde(default)] + pub request_time: Option, + /// + pub request_time_epoch: i64, + /// + #[serde(default, deserialize_with = "nullable_default")] + pub apiid: Option, /// The HTTP method used. Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT. pub http_method: String, /// The stringified value of the specified key-value pair of the context map returned from an API Gateway Lambda authorizer function. @@ -168,6 +188,7 @@ pub struct ApiGatewayRequestContext { /// The identifier API Gateway assigns to your API. pub api_id: String, /// Cofnito identity information + #[serde(default)] pub identity: Identity, } diff --git a/lambda-http/tests/data/apigw_multi_value_proxy_request.json b/lambda-http/tests/data/apigw_multi_value_proxy_request.json index 90f784e2..5b254c8b 100644 --- a/lambda-http/tests/data/apigw_multi_value_proxy_request.json +++ b/lambda-http/tests/data/apigw_multi_value_proxy_request.json @@ -109,6 +109,7 @@ "resourceId": "roq9wj", "stage": "testStage", "requestId": "deef4878-7910-11e6-8f14-25afc3e9ae33", + "requestTimeEpoch": 1583798639428, "identity": { "cognitoIdentityPoolId": null, "accountId": null, diff --git a/lambda-http/tests/data/apigw_no_host.json b/lambda-http/tests/data/apigw_no_host.json index 369c4870..3143c81b 100644 --- a/lambda-http/tests/data/apigw_no_host.json +++ b/lambda-http/tests/data/apigw_no_host.json @@ -26,6 +26,7 @@ "resourceId": "us4z18", "stage": "test", "requestId": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9", + "requestTimeEpoch": 1583798639428, "identity": { "cognitoIdentityPoolId": "", "accountId": "", diff --git a/lambda-http/tests/data/apigw_proxy_request.json b/lambda-http/tests/data/apigw_proxy_request.json index f76d2b8a..3b7cc9d2 100644 --- a/lambda-http/tests/data/apigw_proxy_request.json +++ b/lambda-http/tests/data/apigw_proxy_request.json @@ -27,6 +27,7 @@ "resourceId": "us4z18", "stage": "test", "requestId": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9", + "requestTimeEpoch": 1583798639428, "identity": { "cognitoIdentityPoolId": "", "accountId": "", From 002bd156086bb1ddcfe49691d93321d3f960c8be Mon Sep 17 00:00:00 2001 From: Vassil Kolarov Date: Sat, 15 Jan 2022 14:42:31 +0000 Subject: [PATCH 3/5] updated ApiGatewayContext --- lambda-http/src/request.rs | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lambda-http/src/request.rs b/lambda-http/src/request.rs index b238fab5..5db9cd03 100644 --- a/lambda-http/src/request.rs +++ b/lambda-http/src/request.rs @@ -154,31 +154,23 @@ pub struct ApiGatewayRequestContext { pub account_id: String, /// The identifier that API Gateway assigns to your resource. pub resource_id: String, - /// - #[serde(default, deserialize_with = "nullable_default")] - pub operation_name: Option, /// The deployment stage of the API request (for example, Beta or Prod). pub stage: String, - /// - #[serde(default, deserialize_with = "nullable_default")] + /// The full domain name used to invoke the API. This should be the same as the incoming Host header. pub domain_name: Option, - /// - #[serde(default, deserialize_with = "nullable_default")] + /// The first label of the $context.domainName. This is often used as a caller/customer identifier. pub domain_prefix: Option, /// The ID that API Gateway assigns to the API request. pub request_id: String, /// The path to your resource. For example, for the non-proxy request URI of `https://{rest-api-id.execute-api.{region}.amazonaws.com/{stage}/root/child`, The $context.resourcePath value is /root/child. pub resource_path: String, - /// - #[serde(default, deserialize_with = "nullable_default")] + /// The request protocol, for example, HTTP/1.1. pub protocol: Option, - /// - #[serde(default)] + /// The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm). pub request_time: Option, - /// + /// The Epoch-formatted request time, in milliseconds. pub request_time_epoch: i64, - /// - #[serde(default, deserialize_with = "nullable_default")] + /// The identifier API Gateway assigns to your API. pub apiid: Option, /// The HTTP method used. Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT. pub http_method: String, From 5792450eb1fb33516ac77e1bcd66f152587d127b Mon Sep 17 00:00:00 2001 From: Vassil Kolarov Date: Sat, 15 Jan 2022 14:44:28 +0000 Subject: [PATCH 4/5] run fmt --- lambda-http/src/request.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda-http/src/request.rs b/lambda-http/src/request.rs index 5db9cd03..fd509412 100644 --- a/lambda-http/src/request.rs +++ b/lambda-http/src/request.rs @@ -86,7 +86,7 @@ pub enum LambdaRequest<'a> { body: Option>, #[serde(default)] is_base64_encoded: bool, - request_context: ApiGatewayRequestContext, + request_context: ApiGatewayRequestContext, #[serde(default, deserialize_with = "nullable_default")] resource: Option, }, From 155f949f8ee1ec84b5b5b9e105e3463ec5e3c389 Mon Sep 17 00:00:00 2001 From: Vassil Kolarov Date: Wed, 19 Jan 2022 15:17:56 +0000 Subject: [PATCH 5/5] reverted .gitignore --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 07a174b1..266ec088 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,4 @@ lambda.zip output.json .aws-sam -build.history -.history +build