diff options
author | Matthew Lemon <y@yulqen.org> | 2024-03-11 19:41:29 +0000 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-03-11 19:41:29 +0000 |
commit | b88dc4c9c5e6b37fcc6ac8b55761dcf1351bca9c (patch) | |
tree | f00309d87b8d69d381ff1bbf82fc68fa77892102 | |
parent | bac244e9d1cc2f3af4a63c662f38be60a1bcf7fd (diff) |
Implements the new writeJSON method
-rw-r--r-- | cmd/api/healthcheck.go | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/cmd/api/healthcheck.go b/cmd/api/healthcheck.go index c046995..625f4ca 100644 --- a/cmd/api/healthcheck.go +++ b/cmd/api/healthcheck.go @@ -1,7 +1,6 @@ package main import ( - "encoding/json" "net/http" ) @@ -11,13 +10,10 @@ func (app *application) healthcheckHandler(w http.ResponseWriter, r *http.Reques "environment": app.config.env, "version": version, } - js, err := json.Marshal(data) + err := app.writeJSON(w, http.StatusOK, data, nil) if err != nil { app.logger.Debug("server error", "err", err) http.Error(w, "The server encountered a problem and could not process your request", http.StatusInternalServerError) return } - js = append(js, '\n') - w.Header().Set("Content-Type", "application/json") - w.Write([]byte(js)) } |