From 02bf649c8981af4b46a18d9643386f7227f156a1 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Mon, 11 Mar 2024 19:21:52 +0000 Subject: Adds first bit of JSON --- cmd/api/healthcheck.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cmd/api/healthcheck.go') 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)) } -- cgit v1.2.3