Skip to content

Commit

Permalink
APIGatewayProxyRequestContext: Add new fields (#293)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
RaeesBhatti authored May 20, 2020
1 parent 4e5ba49 commit c67fade
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
25 changes: 15 additions & 10 deletions events/apigw.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,21 @@ type APIGatewayProxyResponse struct {
// APIGatewayProxyRequestContext contains the information to identify the AWS account and resources invoking the
// Lambda function. It also includes Cognito identity information for the caller.
type APIGatewayProxyRequestContext struct {
AccountID string `json:"accountId"`
ResourceID string `json:"resourceId"`
OperationName string `json:"operationName,omitempty"`
Stage string `json:"stage"`
RequestID string `json:"requestId"`
Identity APIGatewayRequestIdentity `json:"identity"`
ResourcePath string `json:"resourcePath"`
Authorizer map[string]interface{} `json:"authorizer"`
HTTPMethod string `json:"httpMethod"`
APIID string `json:"apiId"` // The API Gateway rest API Id
AccountID string `json:"accountId"`
ResourceID string `json:"resourceId"`
OperationName string `json:"operationName,omitempty"`
Stage string `json:"stage"`
DomainName string `json:"domainName"`
DomainPrefix string `json:"domainPrefix"`
RequestID string `json:"requestId"`
Protocol string `json:"protocol"`
Identity APIGatewayRequestIdentity `json:"identity"`
ResourcePath string `json:"resourcePath"`
Authorizer map[string]interface{} `json:"authorizer"`
HTTPMethod string `json:"httpMethod"`
RequestTime string `json:"requestTime"`
RequestTimeEpoch int64 `json:"requestTimeEpoch"`
APIID string `json:"apiId"` // The API Gateway rest API Id
}

// APIGatewayV2HTTPRequest contains data coming from the new HTTP API Gateway
Expand Down
5 changes: 5 additions & 0 deletions events/testdata/apigw-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@
"accountId": "12345678912",
"resourceId": "roq9wj",
"stage": "testStage",
"domainName": "gy415nuibc.execute-api.us-east-2.amazonaws.com",
"domainPrefix": "y0ne18dixk",
"requestId": "deef4878-7910-11e6-8f14-25afc3e9ae33",
"protocol": "HTTP/1.1",
"identity": {
"cognitoIdentityPoolId": "theCognitoIdentityPoolId",
"accountId": "theAccountId",
Expand All @@ -83,6 +86,8 @@
},
"resourcePath": "/{proxy+}",
"httpMethod": "POST",
"requestTime": "15/May/2020:06:01:09 +0000",
"requestTimeEpoch": 1589522469693,
"apiId": "gy415nuibc"
},
"body": "{\r\n\t\"a\": 1\r\n}"
Expand Down
5 changes: 5 additions & 0 deletions events/testdata/apigw-restapi-openapi-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@
"resourceId": "roq9wj",
"operationName": "HelloWorld",
"stage": "testStage",
"domainName": "gy415nuibc.execute-api.us-east-2.amazonaws.com",
"domainPrefix": "y0ne18dixk",
"requestId": "deef4878-7910-11e6-8f14-25afc3e9ae33",
"protocol": "HTTP/1.1",
"identity": {
"cognitoIdentityPoolId": "theCognitoIdentityPoolId",
"accountId": "theAccountId",
Expand All @@ -84,6 +87,8 @@
},
"resourcePath": "/{proxy+}",
"httpMethod": "POST",
"requestTime": "15/May/2020:06:01:09 +0000",
"requestTimeEpoch": 1589522469693,
"apiId": "gy415nuibc"
},
"body": "{\r\n\t\"a\": 1\r\n}"
Expand Down

0 comments on commit c67fade

Please sign in to comment.