From 08d5f36c36fae3332cfc2925e2f7b537397c6b1a Mon Sep 17 00:00:00 2001 From: "Stanislav N. aka pztrn" Date: Wed, 23 Dec 2020 20:48:23 +0500 Subject: [PATCH] Add /api/v1/info for build info output. --- internal/httpserver/handler.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/internal/httpserver/handler.go b/internal/httpserver/handler.go index 745b1fb..c0a5860 100644 --- a/internal/httpserver/handler.go +++ b/internal/httpserver/handler.go @@ -152,6 +152,25 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) _, _ = w.Write(appsList) + return + case "info": + infoData := struct { + Branch string + Build string + CommitHash string + Version string + }{ + Branch: common.Branch, + Build: common.Build, + CommitHash: common.CommitHash, + Version: common.Version, + } + + infoBytes, _ := json.Marshal(infoData) + + w.WriteHeader(http.StatusOK) + _, _ = w.Write(infoBytes) + return case "metrics": handler, found := h.handlers[rInfo.Application]