Skip to content

Commit a502888

Browse files
committed
code cleanup after aider
1 parent d21d791 commit a502888

File tree

1 file changed

+19
-23
lines changed

1 file changed

+19
-23
lines changed

cmd/altinity-mcp/main.go

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ func (a *application) startHTTPServer(cfg config.Config, mcpServer *server.MCPSe
331331
next.ServeHTTP(w, r.WithContext(ctx))
332332
})
333333
}
334-
serverInjectorFunc := func(w http.ResponseWriter, r *http.Request) {
334+
serverInjectorOpenAPI := func(w http.ResponseWriter, r *http.Request) {
335335
ctx := context.WithValue(r.Context(), "clickhouse_jwt_server", a.mcpServer)
336336
a.mcpServer.OpenAPIHandler(w, r.WithContext(ctx))
337337
}
@@ -346,11 +346,15 @@ func (a *application) startHTTPServer(cfg config.Config, mcpServer *server.MCPSe
346346
mux := http.NewServeMux()
347347
mux.Handle("/{token}/http", serverInjector(tokenInjector(httpServer)))
348348
if cfg.Server.OpenAPI {
349-
mux.HandleFunc("/{token}/openapi", serverInjectorFunc)
350-
mux.HandleFunc("/{token}/openapi/list_tables", serverInjectorFunc)
351-
mux.HandleFunc("/{token}/openapi/describe_table", serverInjectorFunc)
352-
mux.HandleFunc("/{token}/openapi/query", serverInjectorFunc)
353-
log.Info().Str("url", fmt.Sprintf("http://%s:%d/{token}/openapi", cfg.Server.Address, cfg.Server.Port)).Msg("Started OpenAPI listening")
349+
mux.HandleFunc("/{token}/openapi", serverInjectorOpenAPI)
350+
mux.HandleFunc("/{token}/openapi/list_tables", serverInjectorOpenAPI)
351+
mux.HandleFunc("/{token}/openapi/describe_table", serverInjectorOpenAPI)
352+
mux.HandleFunc("/{token}/openapi/query", serverInjectorOpenAPI)
353+
protocol := "http"
354+
if cfg.Server.TLS.Enabled {
355+
protocol = "https"
356+
}
357+
log.Info().Str("url", fmt.Sprintf("%s://%s:%d/{token}/openapi", protocol, cfg.Server.Address, cfg.Server.Port)).Msg("Started OpenAPI listening")
354358
}
355359
mux.HandleFunc("/health", a.healthHandler)
356360
httpHandler = mux
@@ -360,23 +364,15 @@ func (a *application) startHTTPServer(cfg config.Config, mcpServer *server.MCPSe
360364
mux := http.NewServeMux()
361365
mux.Handle("/http", serverInjector(httpServer))
362366
if cfg.Server.OpenAPI {
363-
mux.HandleFunc("/openapi", func(w http.ResponseWriter, r *http.Request) {
364-
ctx := context.WithValue(r.Context(), "clickhouse_jwt_server", a.mcpServer)
365-
a.mcpServer.OpenAPIHandler(w, r.WithContext(ctx))
366-
})
367-
mux.HandleFunc("/openapi/list_tables", func(w http.ResponseWriter, r *http.Request) {
368-
ctx := context.WithValue(r.Context(), "clickhouse_jwt_server", a.mcpServer)
369-
a.mcpServer.OpenAPIHandler(w, r.WithContext(ctx))
370-
})
371-
mux.HandleFunc("/openapi/describe_table", func(w http.ResponseWriter, r *http.Request) {
372-
ctx := context.WithValue(r.Context(), "clickhouse_jwt_server", a.mcpServer)
373-
a.mcpServer.OpenAPIHandler(w, r.WithContext(ctx))
374-
})
375-
mux.HandleFunc("/openapi/query", func(w http.ResponseWriter, r *http.Request) {
376-
ctx := context.WithValue(r.Context(), "clickhouse_jwt_server", a.mcpServer)
377-
a.mcpServer.OpenAPIHandler(w, r.WithContext(ctx))
378-
})
379-
log.Info().Str("url", fmt.Sprintf("http://%s:%d/openapi", cfg.Server.Address, cfg.Server.Port)).Msg("Started OpenAPI listening")
367+
mux.HandleFunc("/openapi", serverInjectorOpenAPI)
368+
mux.HandleFunc("/openapi/list_tables", serverInjectorOpenAPI)
369+
mux.HandleFunc("/openapi/describe_table", serverInjectorOpenAPI)
370+
mux.HandleFunc("/openapi/query", serverInjectorOpenAPI)
371+
protocol := "http"
372+
if cfg.Server.TLS.Enabled {
373+
protocol = "https"
374+
}
375+
log.Info().Str("url", fmt.Sprintf("%s://%s:%d/openapi", protocol, cfg.Server.Address, cfg.Server.Port)).Msg("Started OpenAPI listening")
380376
}
381377
mux.HandleFunc("/health", a.healthHandler)
382378
httpHandler = mux

0 commit comments

Comments
 (0)