Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetContentType middleware breaks Content-Type detection for requests #3

Open
jayschwa opened this issue Aug 23, 2017 · 3 comments
Open

Comments

@jayschwa
Copy link

jayschwa commented Aug 23, 2017

The documentation for SetContentType only mentions responses and says nothing of requests:

SetContentType is a middleware that forces response Content-Type.

However, this breaks Content-Type detection for requests in the DefaultDecoder because SetContentType and GetRequestContentType share the same context key.

It's not obvious to me why GetRequestContentType even looks at the context, as that seems to betray the function name. But if that behavior is going to stay, I suggest using a separate context key so that SetContentType does not interfere.

@VojtechVitek
Copy link
Contributor

It looks at context, so you can override the Content-Type on specific routes via a middleware. Ie. you could force application/json on specific endpoint requests.

@jayschwa
Copy link
Author

If it is working as intended, it would be good for SetContentType documentation to mention that it overrides request decoding in addition to responses.

@VojtechVitek
Copy link
Contributor

@jayschwa yeah, that would be great. Would you mind submitting a PR? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants