diff --git a/core/response.go b/core/response.go index 0668109..460f1ad 100644 --- a/core/response.go +++ b/core/response.go @@ -103,8 +103,15 @@ func (r *ProxyResponseWriter) GetProxyResponse() (events.APIGatewayProxyResponse isBase64 = true } + proxyHeaders := make(map[string]string) + + for h := range r.headers { + proxyHeaders[h] = r.headers.Get(h) + } + return events.APIGatewayProxyResponse{ StatusCode: r.status, + Headers: proxyHeaders, MultiValueHeaders: http.Header(r.headers), Body: output, IsBase64Encoded: isBase64, diff --git a/core/response_test.go b/core/response_test.go index 3df207a..d874c97 100644 --- a/core/response_test.go +++ b/core/response_test.go @@ -154,7 +154,7 @@ var _ = Describe("ResponseWriter tests", func() { Expect(err).To(BeNil()) // Headers are not written to `Headers` field - Expect(0).To(Equal(len(proxyResponse.Headers))) + Expect(1).To(Equal(len(proxyResponse.Headers))) Expect(1).To(Equal(len(proxyResponse.MultiValueHeaders["Content-Type"]))) Expect("application/json").To(Equal(proxyResponse.MultiValueHeaders["Content-Type"][0])) }) @@ -168,7 +168,7 @@ var _ = Describe("ResponseWriter tests", func() { Expect(err).To(BeNil()) // Headers are not written to `Headers` field - Expect(0).To(Equal(len(proxyResponse.Headers))) + Expect(2).To(Equal(len(proxyResponse.Headers))) // There are two headers here because Content-Type is always written implicitly Expect(2).To(Equal(len(proxyResponse.MultiValueHeaders["Set-Cookie"]))) diff --git a/go.mod b/go.mod index cee53a7..720e5cb 100644 --- a/go.mod +++ b/go.mod @@ -28,7 +28,7 @@ require ( github.com/json-iterator/go v0.0.0-20180128142709-bca911dae073 github.com/kardianos/govendor v1.0.9 // indirect github.com/kataras/golog v0.0.0-20190624001437-99c81de45f40 // indirect - github.com/kataras/iris v11.1.1+incompatible // indirect + github.com/kataras/iris v11.1.1+incompatible github.com/kataras/pio v0.0.0-20190103105442-ea782b38602d // indirect github.com/klauspost/compress v1.7.4 // indirect github.com/klauspost/cpuid v1.2.1 // indirect