setupRoutes configures all routes
()
| 224 | |
| 225 | // setupRoutes configures all routes |
| 226 | func (s *Server) setupRoutes() { |
| 227 | // Static files (UI SDK demos) - no auth required |
| 228 | s.router.Static("/ui", "./ui") |
| 229 | |
| 230 | // Health check endpoint (no auth required) |
| 231 | if s.config.Observability.HealthCheck.Enabled { |
| 232 | s.router.GET(s.config.Observability.HealthCheck.Endpoint, s.healthCheck) |
| 233 | } |
| 234 | |
| 235 | // Metrics endpoint (no auth required) |
| 236 | if s.config.Observability.Metrics.Enabled { |
| 237 | s.router.GET(s.config.Observability.Metrics.Endpoint, s.metricsHandler) |
| 238 | } |
| 239 | |
| 240 | // WebSocket endpoint (no auth middleware - handles auth internally) |
| 241 | wsHandler := handlers.NewWebSocketHandler(s.store, s.deps.AgentDeps, s.agentRegistry) |
| 242 | s.router.GET("/v1/ws", wsHandler.HandleWebSocket) |
| 243 | |
| 244 | // Dashboard routes (no auth required for Studio UI) |
| 245 | dashboardGroup := s.router.Group("/v1/dashboard") |
| 246 | s.registerDashboardRoutesNoAuth(dashboardGroup) |
| 247 | |
| 248 | // API v1 routes (with authentication) |
| 249 | v1 := s.router.Group("/v1") |
| 250 | |
| 251 | // Apply authentication middleware |
| 252 | if s.config.Auth.APIKey.Enabled { |
| 253 | v1.Use(apiKeyAuthMiddleware(s.config.Auth.APIKey)) |
| 254 | } |
| 255 | if s.config.Auth.JWT.Enabled { |
| 256 | v1.Use(jwtAuthMiddleware(s.config.Auth.JWT)) |
| 257 | } |
| 258 | |
| 259 | // Apply rate limiting |
| 260 | if s.config.RateLimit.Enabled && s.rateLimiter != nil { |
| 261 | v1.Use(ratelimit.Middleware(ratelimit.Config{ |
| 262 | Enabled: s.config.RateLimit.Enabled, |
| 263 | RequestsPerIP: s.config.RateLimit.RequestsPerIP, |
| 264 | WindowSize: s.config.RateLimit.WindowSize, |
| 265 | BurstSize: s.config.RateLimit.BurstSize, |
| 266 | }, s.rateLimiter)) |
| 267 | } |
| 268 | |
| 269 | // Register API routes |
| 270 | s.registerAgentRoutes(v1) |
| 271 | s.registerMemoryRoutes(v1) |
| 272 | s.registerSessionRoutes(v1) |
| 273 | s.registerWorkflowRoutes(v1) |
| 274 | s.registerToolRoutes(v1) |
| 275 | s.registerMiddlewareRoutes(v1) |
| 276 | s.registerSystemRoutes(v1) |
| 277 | s.registerTelemetryRoutes(v1) |
| 278 | s.registerEvalRoutes(v1) |
| 279 | s.registerMCPRoutes(v1) |
| 280 | s.registerA2ARoutes(v1) |
| 281 | s.registerRemoteAgentRoutes(v1) |
| 282 | // Dashboard routes are registered without auth above for Studio UI |
| 283 |
no test coverage detected