Merge pull request #590 from mattrobenolt/patch-1

Return valid json from StatusHandler
This commit is contained in:
Olivier Gambier 2015-06-11 09:51:45 -07:00
commit 1ad9ac497c

View file

@ -195,11 +195,16 @@ func StatusHandler(w http.ResponseWriter, r *http.Request) {
if len(checksStatus) != 0 { if len(checksStatus) != 0 {
w.WriteHeader(http.StatusServiceUnavailable) w.WriteHeader(http.StatusServiceUnavailable)
} }
err := json.NewEncoder(w).Encode(checksStatus) encoder := json.NewEncoder(w)
err := encoder.Encode(checksStatus)
// Parsing of the JSON failed. Returning generic error message // Parsing of the JSON failed. Returning generic error message
if err != nil { if err != nil {
w.Write([]byte("{server_error: 'Could not parse error message'}")) encoder.Encode(struct {
ServerError string `json:"server_error"`
}{
ServerError: "Could not parse error message",
})
} }
} else { } else {
w.WriteHeader(http.StatusNotFound) w.WriteHeader(http.StatusNotFound)