Skip to content

Commit 9281612

Browse files
piotrkubisabmoffatt
authored andcommitted
Add multi-value headers to the API Gateway response (#155)
* Add multi-value headers to the API Gateway response * Add multiValueHeaders into the example response payload * Use proper type for the multiValueHeaders
1 parent 1be8070 commit 9281612

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

events/apigw.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ type APIGatewayProxyRequest struct {
2020

2121
// APIGatewayProxyResponse configures the response to be returned by API Gateway for the request
2222
type APIGatewayProxyResponse struct {
23-
StatusCode int `json:"statusCode"`
24-
Headers map[string]string `json:"headers"`
25-
Body string `json:"body"`
26-
IsBase64Encoded bool `json:"isBase64Encoded,omitempty"`
23+
StatusCode int `json:"statusCode"`
24+
Headers map[string]string `json:"headers"`
25+
MultiValueHeaders map[string][]string `json:"multiValueHeaders"`
26+
Body string `json:"body"`
27+
IsBase64Encoded bool `json:"isBase64Encoded,omitempty"`
2728
}
2829

2930
// APIGatewayProxyRequestContext contains the information to identify the AWS account and resources invoking the

events/testdata/apigw-response.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,24 @@
1919
"X-Forwarded-Port": "443",
2020
"X-Forwarded-Proto": "https"
2121
},
22+
"multiValueHeaders": {
23+
"Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"],
24+
"Accept-Encoding": ["gzip, deflate, lzma, sdch, br"],
25+
"Accept-Language": ["en-US,en;q=0.8"],
26+
"CloudFront-Forwarded-Proto": ["https"],
27+
"CloudFront-Is-Desktop-Viewer": ["true"],
28+
"CloudFront-Is-Mobile-Viewer": ["false"],
29+
"CloudFront-Is-SmartTV-Viewer": ["false"],
30+
"CloudFront-Is-Tablet-Viewer": ["false"],
31+
"CloudFront-Viewer-Country": ["US"],
32+
"Host": ["wt6mne2s9k.execute-api.us-west-2.amazonaws.com"],
33+
"Upgrade-Insecure-Requests": ["1"],
34+
"User-Agent": ["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36 OPR/39.0.2256.48"],
35+
"Via": ["1.1 fb7cca60f0ecd82ce07790c9c5eef16c.cloudfront.net (CloudFront)"],
36+
"X-Amz-Cf-Id": ["nBsWBOrSHMgnaROZJK1wGCZ9PcRcSpq_oSXZNQwQ10OTZL4cimZo3g=="],
37+
"X-Forwarded-For": ["192.168.100.1, 192.168.1.1"],
38+
"X-Forwarded-Port": ["443"],
39+
"X-Forwarded-Proto": ["https"]
40+
},
2241
"body": "Hello World"
2342
}

0 commit comments

Comments
 (0)