httptypes: set headers before call to WriteHeader

This commit is contained in:
Brian Waldon 2014-10-28 11:08:10 -07:00
parent 2b4201c53d
commit 6f851ac885

View File

@ -33,8 +33,8 @@ func (e HTTPError) Error() string {
// TODO(xiangli): handle http write errors
func (e HTTPError) WriteTo(w http.ResponseWriter) {
w.WriteHeader(e.Code)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(e.Code)
b, err := json.Marshal(e)
if err != nil {
panic("unexpected json marshal error")