Review feedback.

Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
pull/4359/head
Tom Wilkie 6 years ago
parent ccb2ee607b
commit f83155b11e

@ -824,9 +824,6 @@ func mergeLabels(primary, secondary []*prompb.Label) []*prompb.Label {
}
func (api *API) respond(w http.ResponseWriter, data interface{}) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
json := jsoniter.ConfigCompatibleWithStandardLibrary
b, err := json.Marshal(&response{
Status: statusSuccess,
@ -834,8 +831,12 @@ func (api *API) respond(w http.ResponseWriter, data interface{}) {
})
if err != nil {
level.Error(api.logger).Log("msg", "error marshalling json response", "err", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
if n, err := w.Write(b); err != nil {
level.Error(api.logger).Log("msg", "error writing response", "n", n, "err", err)
}

Loading…
Cancel
Save