From 701988fca8e839ed57cff053802677ad9f54c5c8 Mon Sep 17 00:00:00 2001 From: Avinash Sridhar Date: Fri, 23 May 2025 12:34:58 -0400 Subject: [PATCH] feat: enhance health check endpoint to include GitHub client ID --- internal/api/handlers/v0/health.go | 14 ++++++++++++-- internal/api/router/v0.go | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/internal/api/handlers/v0/health.go b/internal/api/handlers/v0/health.go index fbce118..07d31b6 100644 --- a/internal/api/handlers/v0/health.go +++ b/internal/api/handlers/v0/health.go @@ -4,12 +4,22 @@ package v0 import ( "encoding/json" "net/http" + + "github.com/modelcontextprotocol/registry/internal/config" ) +type HealthResponse struct { + Status string `json:"status"` + GitHubClientId string `json:"github_client_id"` +} + // HealthHandler returns a handler for health check endpoint -func HealthHandler() http.HandlerFunc { +func HealthHandler(cfg *config.Config) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(map[string]string{"status": "ok"}) + json.NewEncoder(w).Encode(HealthResponse{ + Status: "ok", + GitHubClientId: cfg.GithubClientID, + }) } } diff --git a/internal/api/router/v0.go b/internal/api/router/v0.go index 839dd09..3564d7e 100644 --- a/internal/api/router/v0.go +++ b/internal/api/router/v0.go @@ -13,7 +13,7 @@ import ( // RegisterV0Routes registers all v0 API routes to the provided router func RegisterV0Routes(mux *http.ServeMux, cfg *config.Config, registry service.RegistryService, authService auth.Service) { // Register v0 endpoints - mux.HandleFunc("/v0/health", v0.HealthHandler()) + mux.HandleFunc("/v0/health", v0.HealthHandler(cfg)) mux.HandleFunc("/v0/servers", v0.ServersHandler(registry)) mux.HandleFunc("/v0/servers/{id}", v0.ServersDetailHandler(registry)) mux.HandleFunc("/v0/ping", v0.PingHandler(cfg))