diff --git a/controller/internal/api/api.go b/controller/internal/api/api.go index 00f736e..ac2d7f3 100644 --- a/controller/internal/api/api.go +++ b/controller/internal/api/api.go @@ -70,8 +70,12 @@ func pingHandler(w http.ResponseWriter, r *http.Request) { "ping": "OK", } w.Header().Set("Content-Type", "application/json") - w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(resp) + err := json.NewEncoder(w).Encode(resp) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + } else { + w.WriteHeader(http.StatusOK) + } } func getSystemStatus(w http.ResponseWriter, r *http.Request) { @@ -89,6 +93,10 @@ func getSystemStatus(w http.ResponseWriter, r *http.Request) { } w.Header().Set("Content-Type", "application-json") - w.WriteHeader(http.StatusOK) - json.NewEncoder(w).Encode(resp) + err := json.NewEncoder(w).Encode(resp) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + } else { + w.WriteHeader(http.StatusOK) + } }