From e425d75c00cac5b0b5d4330951af8a15f6f8c6e9 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 12 Mar 2024 14:51:39 +0000 Subject: Wraps the JSON response for healthcheck in an envelope --- cmd/api/healthcheck.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/api/healthcheck.go b/cmd/api/healthcheck.go index 625f4ca..4c0a8fa 100644 --- a/cmd/api/healthcheck.go +++ b/cmd/api/healthcheck.go @@ -5,12 +5,14 @@ import ( ) func (app *application) healthcheckHandler(w http.ResponseWriter, r *http.Request) { - data := map[string]string{ - "status": "available", - "environment": app.config.env, - "version": version, + env := envelope{ + "status": "available", + "system_info": map[string]string{ + "environment": app.config.env, + "version": version, + }, } - err := app.writeJSON(w, http.StatusOK, data, nil) + err := app.writeJSON(w, http.StatusOK, env, 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) -- cgit v1.2.3