()
| 394 | } |
| 395 | |
| 396 | func (s *Server) homeHeartbeatMiddleware() gin.HandlerFunc { |
| 397 | return func(c *gin.Context) { |
| 398 | if s == nil || s.cfg == nil || !s.cfg.Home.Enabled { |
| 399 | c.Next() |
| 400 | return |
| 401 | } |
| 402 | if c != nil && c.Request != nil { |
| 403 | path := c.Request.URL.Path |
| 404 | if strings.HasPrefix(path, "/v0/management/") || path == "/v0/management" || strings.HasPrefix(path, "/v0/resource/plugins/") || path == "/management.html" { |
| 405 | c.Next() |
| 406 | return |
| 407 | } |
| 408 | } |
| 409 | client := home.Current() |
| 410 | if client == nil || !client.HeartbeatOK() { |
| 411 | c.AbortWithStatus(http.StatusServiceUnavailable) |
| 412 | return |
| 413 | } |
| 414 | c.Next() |
| 415 | } |
| 416 | } |
| 417 | |
| 418 | // setupRoutes configures the API routes for the server. |
| 419 | // It defines the endpoints and associates them with their respective handlers. |
no test coverage detected