Skip to content

Commit 70adf9f

Browse files
vascokkVassil Kolarov
and
Vassil Kolarov
authored
Added some missing fields to ApiGateway and ApiGatewayRequestContext (#403)
* added resource field to ApiGateway enum * updated ApiGatewayContext * updated ApiGatewayContext * run fmt * reverted .gitignore Co-authored-by: Vassil Kolarov <[email protected]>
1 parent 917ed63 commit 70adf9f

File tree

5 files changed

+20
-1
lines changed

5 files changed

+20
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ lambda.zip
1111
output.json
1212

1313
.aws-sam
14-
build
14+
build

lambda-http/src/request.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ pub enum LambdaRequest<'a> {
8787
#[serde(default)]
8888
is_base64_encoded: bool,
8989
request_context: ApiGatewayRequestContext,
90+
#[serde(default, deserialize_with = "nullable_default")]
91+
resource: Option<String>,
9092
},
9193
}
9294

@@ -154,10 +156,22 @@ pub struct ApiGatewayRequestContext {
154156
pub resource_id: String,
155157
/// The deployment stage of the API request (for example, Beta or Prod).
156158
pub stage: String,
159+
/// The full domain name used to invoke the API. This should be the same as the incoming Host header.
160+
pub domain_name: Option<String>,
161+
/// The first label of the $context.domainName. This is often used as a caller/customer identifier.
162+
pub domain_prefix: Option<String>,
157163
/// The ID that API Gateway assigns to the API request.
158164
pub request_id: String,
159165
/// 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.
160166
pub resource_path: String,
167+
/// The request protocol, for example, HTTP/1.1.
168+
pub protocol: Option<String>,
169+
/// The CLF-formatted request time (dd/MMM/yyyy:HH:mm:ss +-hhmm).
170+
pub request_time: Option<String>,
171+
/// The Epoch-formatted request time, in milliseconds.
172+
pub request_time_epoch: i64,
173+
/// The identifier API Gateway assigns to your API.
174+
pub apiid: Option<String>,
161175
/// The HTTP method used. Valid values include: DELETE, GET, HEAD, OPTIONS, PATCH, POST, and PUT.
162176
pub http_method: String,
163177
/// 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 {
166180
/// The identifier API Gateway assigns to your API.
167181
pub api_id: String,
168182
/// Cofnito identity information
183+
#[serde(default)]
169184
pub identity: Identity,
170185
}
171186

@@ -436,6 +451,7 @@ impl<'a> From<LambdaRequest<'a>> for http::Request<Body> {
436451
body,
437452
is_base64_encoded,
438453
request_context,
454+
resource: _,
439455
} => {
440456
let builder = http::Request::builder()
441457
.method(http_method)

lambda-http/tests/data/apigw_multi_value_proxy_request.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
"resourceId": "roq9wj",
110110
"stage": "testStage",
111111
"requestId": "deef4878-7910-11e6-8f14-25afc3e9ae33",
112+
"requestTimeEpoch": 1583798639428,
112113
"identity": {
113114
"cognitoIdentityPoolId": null,
114115
"accountId": null,

lambda-http/tests/data/apigw_no_host.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"resourceId": "us4z18",
2727
"stage": "test",
2828
"requestId": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9",
29+
"requestTimeEpoch": 1583798639428,
2930
"identity": {
3031
"cognitoIdentityPoolId": "",
3132
"accountId": "",

lambda-http/tests/data/apigw_proxy_request.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"resourceId": "us4z18",
2828
"stage": "test",
2929
"requestId": "41b45ea3-70b5-11e6-b7bd-69b5aaebc7d9",
30+
"requestTimeEpoch": 1583798639428,
3031
"identity": {
3132
"cognitoIdentityPoolId": "",
3233
"accountId": "",

0 commit comments

Comments
 (0)