The current implementation of EncodeJSONResponse always writes an HTTP response body.
When the status should be http.StatusNoContent, there shouldn't be any response body.
In my own code I've done a check like this:
if e, ok := response.(statusCoder); ok {
w.WriteHeader(e.status())
if e.status() == http.StatusNoContent {
return nil
}
}
Should the EncodeJSONResponse have a check for 204 responses? I can send a PR but wanted to make sure it's wanted first.
The current implementation of
EncodeJSONResponsealways writes an HTTP response body.When the status should be
http.StatusNoContent, there shouldn't be any response body.In my own code I've done a check like this:
Should the EncodeJSONResponse have a check for 204 responses? I can send a PR but wanted to make sure it's wanted first.