Return valid json from StatusHandler
Signed-off-by: Matt Robenolt <matt@ydekproductions.com>
This commit is contained in:
parent
4e1280405a
commit
b684b77a0c
1 changed files with 7 additions and 2 deletions
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue