Skip to content

Commit

Permalink
Add ExtendedRequestId to APIGatewayProxyRequestContext
Browse files Browse the repository at this point in the history
It exists on APIGatewayWebsocketProxyRequestContext but not ExtendedRequestId.
It is however present on non-websocket requests and should be accessible by consumers of this package.

* REST https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
* HTTP https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-logging-variables.html
  • Loading branch information
DanielBauman88 committed Jul 11, 2022
1 parent 0260078 commit fa013cf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
33 changes: 17 additions & 16 deletions events/apigw.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,23 @@ 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"`
DomainName string `json:"domainName"`
DomainPrefix string `json:"domainPrefix"`
RequestID string `json:"requestId"`
Protocol string `json:"protocol"`
Identity APIGatewayRequestIdentity `json:"identity"`
ResourcePath string `json:"resourcePath"`
Path string `json:"path"`
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
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"`
ExtendedRequestID string `json:"extendedRequestId"`
Protocol string `json:"protocol"`
Identity APIGatewayRequestIdentity `json:"identity"`
ResourcePath string `json:"resourcePath"`
Path string `json:"path"`
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
1 change: 1 addition & 0 deletions events/testdata/apigw-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"domainName": "gy415nuibc.execute-api.us-east-2.amazonaws.com",
"domainPrefix": "y0ne18dixk",
"requestId": "deef4878-7910-11e6-8f14-25afc3e9ae33",
"extendedRequestId": "TWegAcC4EowCHnA=",
"protocol": "HTTP/1.1",
"identity": {
"cognitoIdentityPoolId": "theCognitoIdentityPoolId",
Expand Down
1 change: 1 addition & 0 deletions events/testdata/apigw-restapi-openapi-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"domainName": "gy415nuibc.execute-api.us-east-2.amazonaws.com",
"domainPrefix": "y0ne18dixk",
"requestId": "deef4878-7910-11e6-8f14-25afc3e9ae33",
"extendedRequestId": "TWegAcC4EowCHnA=",
"protocol": "HTTP/1.1",
"identity": {
"cognitoIdentityPoolId": "theCognitoIdentityPoolId",
Expand Down

0 comments on commit fa013cf

Please sign in to comment.