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 197 forks source link

Detect Content Type on Write #16

Closed haydenwoodhead closed 6 years ago

haydenwoodhead commented 6 years ago

It would be nice if this detected content type on Write (just as the standard library does) rather than leave it unset.

I would be willing to work on this.

sapessi commented 6 years ago

@haydenwoodhead - what are you trying to accomplish?

haydenwoodhead commented 6 years ago

I didn't do a very good job of explaining.

I am trying to have my lambda project return html. If I migrate my project from the http standard library to aws-lamda-go-api-proxy the content type of my pages is no longer set to text/html instead it defaults to application/json if no other content type is set. I can solve this my manually by setting my content type.

What I am proposing is to call http.DetectContentType on write if no other content type is set. This is what the standard library does and I think would make this project more of a 'drop-in' replacement for it.

sapessi commented 6 years ago

Ah, thanks @haydenwoodhead, makes sense. I'll do some tests with it over the next couple of days and update the framework.

sapessi commented 6 years ago

Addressed in the latest commit.