github.com/shurcooL/issuesapp/...

Improve use of http.Error. #20

Opendmitshur opened this issue 3 years ago
dmitshur commented 3 years ago

Calling it after the header has been written (likely with the wrong content-type) is incorrect and shouldn't be done.

Write Preview Markdown
dmitshur commented 3 years ago

A good pattern I've since found to take care of this is to have a func(w http.ResponseWriter, req *http.Request) error handler signature, and keep track of whether the response writer has been written to. See here.

Write Preview Markdown
to comment.