Skip to content

Commit c67fade

Browse files
authored
APIGatewayProxyRequestContext: Add new fields (#293)
* APIGatewayProxyRequestContext: Add new fields Add DomainName and DomainPrefix to APIGatewayProxyRequestContext * Add RequestTime and RequestTimeEpoch * Update test data * Add protocol field * Update apigw-restapi-openapi-request.json
1 parent 4e5ba49 commit c67fade

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

events/apigw.go

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,21 @@ type APIGatewayProxyResponse struct {
3030
// APIGatewayProxyRequestContext contains the information to identify the AWS account and resources invoking the
3131
// Lambda function. It also includes Cognito identity information for the caller.
3232
type APIGatewayProxyRequestContext struct {
33-
AccountID string `json:"accountId"`
34-
ResourceID string `json:"resourceId"`
35-
OperationName string `json:"operationName,omitempty"`
36-
Stage string `json:"stage"`
37-
RequestID string `json:"requestId"`
38-
Identity APIGatewayRequestIdentity `json:"identity"`
39-
ResourcePath string `json:"resourcePath"`
40-
Authorizer map[string]interface{} `json:"authorizer"`
41-
HTTPMethod string `json:"httpMethod"`
42-
APIID string `json:"apiId"` // The API Gateway rest API Id
33+
AccountID string `json:"accountId"`
34+
ResourceID string `json:"resourceId"`
35+
OperationName string `json:"operationName,omitempty"`
36+
Stage string `json:"stage"`
37+
DomainName string `json:"domainName"`
38+
DomainPrefix string `json:"domainPrefix"`
39+
RequestID string `json:"requestId"`
40+
Protocol string `json:"protocol"`
41+
Identity APIGatewayRequestIdentity `json:"identity"`
42+
ResourcePath string `json:"resourcePath"`
43+
Authorizer map[string]interface{} `json:"authorizer"`
44+
HTTPMethod string `json:"httpMethod"`
45+
RequestTime string `json:"requestTime"`
46+
RequestTimeEpoch int64 `json:"requestTimeEpoch"`
47+
APIID string `json:"apiId"` // The API Gateway rest API Id
4348
}
4449

4550
// APIGatewayV2HTTPRequest contains data coming from the new HTTP API Gateway

events/testdata/apigw-request.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@
6060
"accountId": "12345678912",
6161
"resourceId": "roq9wj",
6262
"stage": "testStage",
63+
"domainName": "gy415nuibc.execute-api.us-east-2.amazonaws.com",
64+
"domainPrefix": "y0ne18dixk",
6365
"requestId": "deef4878-7910-11e6-8f14-25afc3e9ae33",
66+
"protocol": "HTTP/1.1",
6467
"identity": {
6568
"cognitoIdentityPoolId": "theCognitoIdentityPoolId",
6669
"accountId": "theAccountId",
@@ -83,6 +86,8 @@
8386
},
8487
"resourcePath": "/{proxy+}",
8588
"httpMethod": "POST",
89+
"requestTime": "15/May/2020:06:01:09 +0000",
90+
"requestTimeEpoch": 1589522469693,
8691
"apiId": "gy415nuibc"
8792
},
8893
"body": "{\r\n\t\"a\": 1\r\n}"

events/testdata/apigw-restapi-openapi-request.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@
6161
"resourceId": "roq9wj",
6262
"operationName": "HelloWorld",
6363
"stage": "testStage",
64+
"domainName": "gy415nuibc.execute-api.us-east-2.amazonaws.com",
65+
"domainPrefix": "y0ne18dixk",
6466
"requestId": "deef4878-7910-11e6-8f14-25afc3e9ae33",
67+
"protocol": "HTTP/1.1",
6568
"identity": {
6669
"cognitoIdentityPoolId": "theCognitoIdentityPoolId",
6770
"accountId": "theAccountId",
@@ -84,6 +87,8 @@
8487
},
8588
"resourcePath": "/{proxy+}",
8689
"httpMethod": "POST",
90+
"requestTime": "15/May/2020:06:01:09 +0000",
91+
"requestTimeEpoch": 1589522469693,
8792
"apiId": "gy415nuibc"
8893
},
8994
"body": "{\r\n\t\"a\": 1\r\n}"

0 commit comments

Comments
 (0)