From b2f64037e2925dea80cecd9eada3e530a8092a62 Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Wed, 17 Apr 2024 16:23:15 -0600 Subject: [PATCH] GET /api/v1/version --- main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/main.go b/main.go index b5ef585..bc83195 100644 --- a/main.go +++ b/main.go @@ -85,6 +85,7 @@ func listenAndServe(ctx context.Context, cfg Config) chan error { func newHandler(cfg Config) http.HandlerFunc { mux := http.NewServeMux() + mux.Handle("GET /api/v1/version", http.HandlerFunc(newHandlerGetAPIV1Version)) mux.Handle("POST /api/v1/events/slack", http.HandlerFunc(newHandlerPostAPIV1EventsSlack(cfg))) mux.Handle("PUT /api/v1/rpc/scrapeslack", http.HandlerFunc(newHandlerPutAPIV1RPCScrapeSlack(cfg))) @@ -99,6 +100,12 @@ func newHandler(cfg Config) http.HandlerFunc { } } +var Version = "undef" + +func newHandlerGetAPIV1Version(w http.ResponseWriter, _ *http.Request) { + json.NewEncoder(w).Encode(map[string]any{"version": Version}) +} + func newHandlerPutAPIV1RPCScrapeSlack(cfg Config) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if !basicAuth(cfg, w, r) {