Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ lambda.zip
output.json

.aws-sam
build
build.history
.history
16 changes: 16 additions & 0 deletions lambda-http/src/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
},
}

Expand Down Expand Up @@ -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.
Expand All @@ -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,
}

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
"resourceId": "roq9wj",
"stage": "testStage",
"requestId": "deef4878-7910-11e6-8f14-25afc3e9ae33",
"requestTimeEpoch": 1583798639428,
"identity": {
"cognitoIdentityPoolId": null,
"accountId": null,
Expand Down
1 change: 1 addition & 0 deletions lambda-http/tests/data/apigw_no_host.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"resourceId": "us4z18",
"stage": "test",
"requestId": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9",
"requestTimeEpoch": 1583798639428,
"identity": {
"cognitoIdentityPoolId": "",
"accountId": "",
Expand Down
1 change: 1 addition & 0 deletions lambda-http/tests/data/apigw_proxy_request.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"resourceId": "us4z18",
"stage": "test",
"requestId": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9",
"requestTimeEpoch": 1583798639428,
"identity": {
"cognitoIdentityPoolId": "",
"accountId": "",
Expand Down