Skip to content

EncodeJSONResponse does not account for http.StatusNoContent #435

@groob

Description

@groob

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions