mirror of
https://github.com/prometheus/prometheus
synced 2025-01-30 11:44:07 +00:00
Review feedback.
Signed-off-by: Tom Wilkie <tom.wilkie@gmail.com>
This commit is contained in:
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…
Reference in New Issue
Block a user