Skip to content
This repository has been archived by the owner on Dec 20, 2024. It is now read-only.

Commit

Permalink
version: add error handling
Browse files Browse the repository at this point in the history
Signed-off-by: hwdef <[email protected]>
  • Loading branch information
hwdef committed Oct 16, 2019
1 parent 0d2bbbe commit 4d50854
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ func Handler(w http.ResponseWriter, r *http.Request) {
data, err := json.Marshal(DFVersion)
if err != nil {
http.Error(w, fmt.Sprintf("error encoding JSON: %s", err), http.StatusInternalServerError)
} else if _, err := w.Write(data); err != nil {
http.Error(w, fmt.Sprintf("error writing the data to the connection: %s", err), http.StatusInternalServerError)
} else {
w.WriteHeader(http.StatusOK)
w.Write(data)
}
}

Expand Down

0 comments on commit 4d50854

Please sign in to comment.