Skip to content

Commit

Permalink
Fixed issue with not checking error return
Browse files Browse the repository at this point in the history
  • Loading branch information
jm20122012 committed Jul 3, 2024
1 parent 6089eb0 commit 135045b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions controller/internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
}

0 comments on commit 135045b

Please sign in to comment.