From 928161204cad89472f9e6b5dd49ce16bc91230de Mon Sep 17 00:00:00 2001 From: Piotr Kubisa Date: Fri, 4 Jan 2019 16:44:40 +0100 Subject: [PATCH] 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 --- events/apigw.go | 9 +++++---- events/testdata/apigw-response.json | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/events/apigw.go b/events/apigw.go index 86c67a31..72e68c62 100644 --- a/events/apigw.go +++ b/events/apigw.go @@ -20,10 +20,11 @@ type APIGatewayProxyRequest struct { // APIGatewayProxyResponse configures the response to be returned by API Gateway for the request type APIGatewayProxyResponse struct { - StatusCode int `json:"statusCode"` - Headers map[string]string `json:"headers"` - Body string `json:"body"` - IsBase64Encoded bool `json:"isBase64Encoded,omitempty"` + StatusCode int `json:"statusCode"` + Headers map[string]string `json:"headers"` + MultiValueHeaders map[string][]string `json:"multiValueHeaders"` + Body string `json:"body"` + IsBase64Encoded bool `json:"isBase64Encoded,omitempty"` } // APIGatewayProxyRequestContext contains the information to identify the AWS account and resources invoking the diff --git a/events/testdata/apigw-response.json b/events/testdata/apigw-response.json index e3620fb4..c682b9aa 100644 --- a/events/testdata/apigw-response.json +++ b/events/testdata/apigw-response.json @@ -19,5 +19,24 @@ "X-Forwarded-Port": "443", "X-Forwarded-Proto": "https" }, + "multiValueHeaders": { + "Accept": ["text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"], + "Accept-Encoding": ["gzip, deflate, lzma, sdch, br"], + "Accept-Language": ["en-US,en;q=0.8"], + "CloudFront-Forwarded-Proto": ["https"], + "CloudFront-Is-Desktop-Viewer": ["true"], + "CloudFront-Is-Mobile-Viewer": ["false"], + "CloudFront-Is-SmartTV-Viewer": ["false"], + "CloudFront-Is-Tablet-Viewer": ["false"], + "CloudFront-Viewer-Country": ["US"], + "Host": ["wt6mne2s9k.execute-api.us-west-2.amazonaws.com"], + "Upgrade-Insecure-Requests": ["1"], + "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"], + "Via": ["1.1 fb7cca60f0ecd82ce07790c9c5eef16c.cloudfront.net (CloudFront)"], + "X-Amz-Cf-Id": ["nBsWBOrSHMgnaROZJK1wGCZ9PcRcSpq_oSXZNQwQ10OTZL4cimZo3g=="], + "X-Forwarded-For": ["192.168.100.1, 192.168.1.1"], + "X-Forwarded-Port": ["443"], + "X-Forwarded-Proto": ["https"] + }, "body": "Hello World" } \ No newline at end of file