Improve use of http.Error. #20

Closeddmitshur opened this issue 4 years ago
dmitshur commented 4 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
dmitshur commented 1 week ago

Resolved a while ago in commit 431bb22d.

Write Preview Markdown
dmitshur closed this 1 week ago
to comment.