awslabs / aws-lambda-go-api-proxy

lambda-go-api-proxy makes it easy to port APIs written with Go frameworks such as Gin (https://gin-gonic.github.io/gin/ ) to AWS Lambda and Amazon API Gateway.
Apache License 2.0
1.05k stars 198 forks source link

Are Headers absolutely required in response? #3

Closed dave-malone closed 6 years ago

dave-malone commented 6 years ago

An http.HandlerFunc can return a response without any headers by default, and as far as I know, it's a valid http response to have an empty set of headers.

https://github.com/awslabs/aws-lambda-go-api-proxy/blob/master/core/response.go#L63,L65

sapessi commented 6 years ago

I'd be suspicious of responses that return 0 headers. Is there a case where this may happen?

dave-malone commented 6 years ago

The default behavior of Golang's http.HandlerFunc is to write a response without headers (headers slice is empty). Enforcing that a header is always returned would create an awkward scenario for developers who wouldn't normally use any headers in their response (see my PR's test case for handlerfunc).

sapessi commented 6 years ago

Done.