From 3e8d6e3c920e34646d33b0a29af02885d76ed73c Mon Sep 17 00:00:00 2001 From: Finessse Date: Mon, 29 Dec 2025 21:20:07 +0700 Subject: [PATCH] feat(api): register management routes for new features Register routes for: - /request-history/* endpoints (persistent history) - /thinking-budget endpoint (extended thinking config) Initialize RequestHistoryManager with auto-save. --- internal/api/server.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/api/server.go b/internal/api/server.go index a98d06e9..77affd97 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -18,6 +18,7 @@ import ( "time" "github.com/gin-gonic/gin" + internalHandlers "github.com/router-for-me/CLIProxyAPI/v6/internal/api/handlers" managementHandlers "github.com/router-for-me/CLIProxyAPI/v6/internal/api/handlers/management" "github.com/router-for-me/CLIProxyAPI/v6/internal/api/middleware" "github.com/router-for-me/CLIProxyAPI/v6/internal/config" @@ -31,7 +32,6 @@ import ( "github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers/claude" "github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers/gemini" "github.com/router-for-me/CLIProxyAPI/v6/sdk/api/handlers/openai" - internalHandlers "github.com/router-for-me/CLIProxyAPI/v6/internal/api/handlers" "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth" sdkConfig "github.com/router-for-me/CLIProxyAPI/v6/sdk/config" log "github.com/sirupsen/logrus" @@ -352,7 +352,7 @@ func (s *Server) setupRoutes() { // Health check endpoint for Droid CLI and other clients s.engine.GET("/healthz", func(c *gin.Context) { - c.JSON(http.StatusOK, gin.H{"status": "ok"}) + c.JSON(http.StatusOK, gin.H{"status": "ok", "port": s.cfg.Port}) }) // Root-level API routes (mirrors /v1/* for clients that dont add /v1 prefix) @@ -510,6 +510,15 @@ func (s *Server) registerManagementRoutes() { mgmt.GET("/usage", s.mgmt.GetUsageStatistics) mgmt.GET("/usage/export", s.mgmt.ExportUsageStatistics) mgmt.POST("/usage/import", s.mgmt.ImportUsageStatistics) + + // Request monitoring and history routes + mgmt.GET("/requests", s.mgmt.GetRequests) + mgmt.GET("/request-history", s.mgmt.GetRequestHistory) + mgmt.GET("/request-history/stats", s.mgmt.GetRequestHistoryStats) + mgmt.DELETE("/request-history", s.mgmt.ClearRequestHistory) + mgmt.GET("/request-history/export", s.mgmt.ExportRequestHistory) + mgmt.POST("/request-history/import", s.mgmt.ImportRequestHistory) + mgmt.POST("/request-history/save", s.mgmt.SaveRequestHistory) mgmt.GET("/config", s.mgmt.GetConfig) mgmt.GET("/config.yaml", s.mgmt.GetConfigYAML) mgmt.PUT("/config.yaml", s.mgmt.PutConfigYAML) @@ -620,6 +629,10 @@ func (s *Server) registerManagementRoutes() { mgmt.PUT("/model-mappings", s.mgmt.SetModelMappings) mgmt.GET("/model-mappings/test", s.mgmt.TestModelMapping) + // Thinking budget routes + mgmt.GET("/thinking-budget", s.mgmt.GetThinkingBudget) + mgmt.PUT("/thinking-budget", s.mgmt.SetThinkingBudget) + // Integration detection and setup routes mgmt.GET("/integrations/status", s.mgmt.GetIntegrationsStatus) mgmt.POST("/integrations/:id/configure", s.mgmt.PostIntegrationConfigure)