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) {