web-api-custom-headers example is misleading
dacort opened this issue · comments
Hi there, thanks for putting this project together - makes it significantly easier to build a web API on top of Lambda. 👏
I ran into an issue using the customer headers in the web-api-custom-headers
example.
Specifically, the example shows passing a custom header for "Content-Type", which led me to believe this was the way to set the content type of a response. Unfortunately, this causes Lambda to send quoted responses.
For example
"this is some\ntext"
instead of
this is some
text
After looking at the web-serving-html
example, I noticed a special contentType
parameter. When using that, the responses are unquoted, as expected.
I would recommend making it clear somewhere of this behavior, or updating the custom headers example to use the contentType
parameter - it was pretty confusing and took a while to track down what was going on.
Hi @dacort,
You can read more about response content types here in API Builder documentation. Also check the explanation for limited custom headers support here.
This can and probably should be linked in README file for that example.
Why does the explanation for custom headers use the Content-Type
key in the headers value? Is that different from the contentType
parameter specified in the docs?
That's why I'm confused, because if you specify a Content-Type
header, it doesn't actually format the response properly so the custom headers documentation is misleading.
@dacort - I think your expectation is reasonable, and defining a content type header should allow you to set the content type. I need to play around with this a bit, but I'll make it work like that.
2.0 deals with headers the way you expect, so setting a dynamic response content type will change it correctly for the response format as well.