go-chi / go-chi/render

SetContentType middleware breaks Content-Type detection for requests

Open
#3 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
339
Forks
66
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.