aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Lemon <y@yulqen.org>2024-03-11 19:21:52 +0000
committerMatthew Lemon <y@yulqen.org>2024-03-11 19:21:52 +0000
commit02bf649c8981af4b46a18d9643386f7227f156a1 (patch)
tree6998a160f58d787a71cdb15e5366f95969951b53
parent10a9c0bc1b6287d69e13126a85708322a26e0bef (diff)
Adds first bit of JSON
-rw-r--r--cmd/api/healthcheck.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/cmd/api/healthcheck.go b/cmd/api/healthcheck.go
index 68bed0d..c4f52f2 100644
--- a/cmd/api/healthcheck.go
+++ b/cmd/api/healthcheck.go
@@ -6,7 +6,8 @@ import (
)
func (app *application) healthcheckHandler(w http.ResponseWriter, r *http.Request) {
- fmt.Fprintln(w, "status: available")
- fmt.Fprintf(w, "environment: %s\n", app.config.env)
- fmt.Fprintf(w, "version: %s\n", version)
+ js := `{"status": "available", "environment": %q, "version": %q}`
+ js = fmt.Sprintf(js, app.config.env, version)
+ w.Header().Set("Content-Type", "application/json")
+ w.Write([]byte(js))
}