Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added some missing fields to ApiGateway and ApiGatewayRequestContext #403

Merged
merged 5 commits into from
Jan 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -11,4 +11,4 @@ lambda.zip
output.json

.aws-sam
build
build
16 changes: 16 additions & 0 deletions lambda-http/src/request.rs
Original file line number Diff line number Diff line change
@@ -87,6 +87,8 @@ pub enum LambdaRequest<'a> {
#[serde(default)]
is_base64_encoded: bool,
request_context: ApiGatewayRequestContext,
#[serde(default, deserialize_with = "nullable_default")]
resource: Option<String>,
},
}

@@ -154,10 +156,22 @@ pub struct ApiGatewayRequestContext {
pub resource_id: String,
/// The deployment stage of the API request (for example, Beta or Prod).
pub stage: String,
/// The full domain name used to invoke the API. This should be the same as the incoming Host header.
pub domain_name: Option<String>,
/// The first label of the $context.domainName. This is often used as a caller/customer identifier.
pub domain_prefix: Option<String>,
/// 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,
/// The request protocol, for example, HTTP/1.1.
pub protocol: Option<String>,
/// The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm).
pub request_time: Option<String>,
/// The Epoch-formatted request time, in milliseconds.
pub request_time_epoch: i64,
/// The identifier API Gateway assigns to your API.
pub apiid: Option<String>,
/// 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.
@@ -166,6 +180,7 @@ pub struct ApiGatewayRequestContext {
/// The identifier API Gateway assigns to your API.
pub api_id: String,
/// Cofnito identity information
#[serde(default)]
pub identity: Identity,
}

@@ -436,6 +451,7 @@ impl<'a> From<LambdaRequest<'a>> for http::Request<Body> {
body,
is_base64_encoded,
request_context,
resource: _,
} => {
let builder = http::Request::builder()
.method(http_method)
Original file line number Diff line number Diff line change
@@ -109,6 +109,7 @@
"resourceId": "roq9wj",
"stage": "testStage",
"requestId": "deef4878-7910-11e6-8f14-25afc3e9ae33",
"requestTimeEpoch": 1583798639428,
"identity": {
"cognitoIdentityPoolId": null,
"accountId": null,
1 change: 1 addition & 0 deletions lambda-http/tests/data/apigw_no_host.json
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@
"resourceId": "us4z18",
"stage": "test",
"requestId": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9",
"requestTimeEpoch": 1583798639428,
"identity": {
"cognitoIdentityPoolId": "",
"accountId": "",
1 change: 1 addition & 0 deletions lambda-http/tests/data/apigw_proxy_request.json
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
"resourceId": "us4z18",
"stage": "test",
"requestId": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9",
"requestTimeEpoch": 1583798639428,
"identity": {
"cognitoIdentityPoolId": "",
"accountId": "",