From ed01699366bd59e527f4d9f65ccce0cf5565a433 Mon Sep 17 00:00:00 2001 From: Yunhe Liu Date: Wed, 9 Aug 2023 20:38:25 +0000 Subject: [PATCH] make health check reponse idiomatic --- app/api.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/api.go b/app/api.go index f15372d3..d85e8c25 100644 --- a/app/api.go +++ b/app/api.go @@ -288,7 +288,14 @@ func (a *App) handleClusteringGet(w http.ResponseWriter, r *http.Request) { } func (a *App) handleHealthzGet(w http.ResponseWriter, r *http.Request) { - w.Write([]byte("I'm healthy!\n")) + s := map[string]string{"status": "healthy",} + b, err := json.Marshal(s) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + json.NewEncoder(w).Encode(APIErrors{Errors: []string{err.Error()}}) + return + } + w.Write(b) } func (a *App) handleClusteringMembersGet(w http.ResponseWriter, r *http.Request) {