Skip to content

Commit

Permalink
fix: handle error from w.Write() in http helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
logan-bobo committed Jun 13, 2024
1 parent 6d68c1e commit 3b863aa
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion httphelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ func respondWithJSON(w http.ResponseWriter, status int, payload interface{}) {

w.Header().Set("content-type", "application/json")
w.WriteHeader(status)
w.Write(data)
_, err = w.Write(data)

if err != nil {
log.Println("could not write data to response writer")
}
}

func respondWithError(w http.ResponseWriter, code int, msg string) {
Expand Down

0 comments on commit 3b863aa

Please sign in to comment.