|
| 1 | +// Copyright 2022 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 2 | + |
| 3 | +package events |
| 4 | + |
| 5 | +// LambdaHTTPRequest contains data coming from the new HTTP API Gateway |
| 6 | +type LambdaHTTPRequest struct { |
| 7 | + Version string `json:"version"` // Version is expected to always be `"2.0"` |
| 8 | + RouteKey string `json:"routeKey"` // RouteKey is expected to always be `"$default"` |
| 9 | + RawPath string `json:"rawPath"` |
| 10 | + RawQueryString string `json:"rawQueryString"` |
| 11 | + Cookies []string `json:"cookies,omitempty"` |
| 12 | + Headers map[string]string `json:"headers"` |
| 13 | + QueryStringParameters map[string]string `json:"queryStringParameters,omitempty"` |
| 14 | + RequestContext LambdaHTTPRequestContext `json:"requestContext"` |
| 15 | + Body string `json:"body,omitempty"` |
| 16 | + IsBase64Encoded bool `json:"isBase64Encoded"` |
| 17 | +} |
| 18 | + |
| 19 | +// LambdaHTTPRequestContext contains the information to identify the AWS account and resources invoking the Lambda function. |
| 20 | +type LambdaHTTPRequestContext struct { |
| 21 | + RouteKey string `json:"routeKey"` // RouteKey is expected to always be `"$default"` |
| 22 | + AccountID string `json:"accountId"` |
| 23 | + Stage string `json:"stage"` // Stage is expected to always be `"$default"` |
| 24 | + RequestID string `json:"requestId"` |
| 25 | + Authorizer *LambdaHTTPRequestContextAuthorizerDescription `json:"authorizer,omitempty"` |
| 26 | + APIID string `json:"apiId"` // APIID is the Lambda URL ID |
| 27 | + DomainName string `json:"domainName"` // DomainName is of the format `"<url-id>.lambda-url.<region>.on.aws"` |
| 28 | + DomainPrefix string `json:"domainPrefix"` // DomainPrefix is the Lambda URL ID |
| 29 | + Time string `json:"time"` |
| 30 | + TimeEpoch int64 `json:"timeEpoch"` |
| 31 | + HTTP LambdaHTTPRequestContextHTTPDescription `json:"http"` |
| 32 | +} |
| 33 | + |
| 34 | +// LambdaHTTPRequestContextAuthorizerDescription contains authorizer information for the request context. |
| 35 | +type LambdaHTTPRequestContextAuthorizerDescription struct { |
| 36 | + IAM *LambdaHTTPRequestContextAuthorizerIAMDescription `json:"iam,omitempty"` |
| 37 | +} |
| 38 | + |
| 39 | +// LambdaHTTPRequestContextAuthorizerIAMDescription contains IAM information for the request context. |
| 40 | +type LambdaHTTPRequestContextAuthorizerIAMDescription struct { |
| 41 | + AccessKey string `json:"accessKey"` |
| 42 | + AccountID string `json:"accountId"` |
| 43 | + CallerID string `json:"callerId"` |
| 44 | + UserARN string `json:"userArn"` |
| 45 | + UserID string `json:"userId"` |
| 46 | +} |
| 47 | + |
| 48 | +// LambdaHTTPRequestContextHTTPDescription contains HTTP information for the request context. |
| 49 | +type LambdaHTTPRequestContextHTTPDescription struct { |
| 50 | + Method string `json:"method"` |
| 51 | + Path string `json:"path"` |
| 52 | + Protocol string `json:"protocol"` |
| 53 | + SourceIP string `json:"sourceIp"` |
| 54 | + UserAgent string `json:"userAgent"` |
| 55 | +} |
| 56 | + |
| 57 | +// LambdaHTTPResponse configures the response to be returned by API Gateway V2 for the request |
| 58 | +type LambdaHTTPResponse struct { |
| 59 | + StatusCode int `json:"statusCode"` |
| 60 | + Headers map[string]string `json:"headers"` |
| 61 | + Body string `json:"body"` |
| 62 | + IsBase64Encoded bool `json:"isBase64Encoded"` |
| 63 | + Cookies []string `json:"cookies"` |
| 64 | +} |
0 commit comments