Skip to content

Commit f6e9702

Browse files
authored
chore(http): use constants for endpoints
Signed-off-by: Marc Nuri <[email protected]>
1 parent 4d994d3 commit f6e9702

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

pkg/http/authorization.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
func AuthorizationMiddleware(requireOAuth bool, serverURL string, mcpServer *mcp.Server) func(http.Handler) http.Handler {
2424
return func(next http.Handler) http.Handler {
2525
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
26-
if r.URL.Path == "/healthz" || r.URL.Path == "/.well-known/oauth-protected-resource" {
26+
if r.URL.Path == healthEndpoint || r.URL.Path == oauthProtectedResourceEndpoint {
2727
next.ServeHTTP(w, r)
2828
return
2929
}

pkg/http/http.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ import (
1616
"github.com/manusa/kubernetes-mcp-server/pkg/mcp"
1717
)
1818

19-
const oauthProtectedResourceEndpoint = "/.well-known/oauth-protected-resource"
19+
const (
20+
oauthProtectedResourceEndpoint = "/.well-known/oauth-protected-resource"
21+
healthEndpoint = "/healthz"
22+
mcpEndpoint = "/mcp"
23+
sseEndpoint = "/sse"
24+
sseMessageEndpoint = "/message"
25+
)
2026

2127
func Serve(ctx context.Context, mcpServer *mcp.Server, staticConfig *config.StaticConfig) error {
2228
mux := http.NewServeMux()
@@ -32,10 +38,10 @@ func Serve(ctx context.Context, mcpServer *mcp.Server, staticConfig *config.Stat
3238

3339
sseServer := mcpServer.ServeSse(staticConfig.SSEBaseURL, httpServer)
3440
streamableHttpServer := mcpServer.ServeHTTP(httpServer)
35-
mux.Handle("/sse", sseServer)
36-
mux.Handle("/message", sseServer)
37-
mux.Handle("/mcp", streamableHttpServer)
38-
mux.HandleFunc("/healthz", func(w http.ResponseWriter, r *http.Request) {
41+
mux.Handle(sseEndpoint, sseServer)
42+
mux.Handle(sseMessageEndpoint, sseServer)
43+
mux.Handle(mcpEndpoint, streamableHttpServer)
44+
mux.HandleFunc(healthEndpoint, func(w http.ResponseWriter, r *http.Request) {
3945
w.WriteHeader(http.StatusOK)
4046
})
4147
mux.HandleFunc(oauthProtectedResourceEndpoint, func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)