Handle JSON report marshalling error

This commit is contained in:
Adam Harrison committed 2015-10-13 17:04:56 +01:00
1 parent 91afa7f7f4
commit ddfc8c2fa4
1 file changed
+6 -1
+6 -1
View File
@@ -161,7 +161,12 @@ func HandleHTTP(muxRouter *mux.Router, version string, router *weave.Router, all
}
muxRouter.Methods("GET").Path("/report").Headers("Accept", "application/json").HandlerFunc(
func(w http.ResponseWriter, r *http.Request) {
json, _ := json.MarshalIndent(status(), "", " ")
json, err := json.MarshalIndent(status(), "", " ")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Log.Error("Error during report marshalling: ", err)
return
}
w.Header().Set("Content-Type", "application/json")
w.Write(json)
})