GET /api/v1/version

main
Bel LaPointe 2024-04-17 16:23:15 -06:00
parent fbd151f9ef
commit b2f64037e2
1 changed files with 7 additions and 0 deletions

View File

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