Using go1.6
I recently saw code that did the following:
func serveHTTP(resp http.ResponseWriter, req *http.Request) {
...
if err := foo(); err != nil {
http.Error(resp, err.Error(), http.StatusInternalServerError)
}
if err := bar(); err != nil {
http.Error(resp, err.Error(), http.StatusInternalServerError)
}
}
The assumption made was that http.Error() terminates the current handler in some magical way. Instead, Error simply sets the headers and writes the body message, and it is the programmer's responsibility to return. We should document this.
Using
go1.6I recently saw code that did the following:
The assumption made was that http.Error() terminates the current handler in some magical way. Instead, Error simply sets the headers and writes the body message, and it is the programmer's responsibility to return. We should document this.