MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / homeHeartbeatMiddleware

Method homeHeartbeatMiddleware

internal/api/server.go:396–416  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

394}
395
396func (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.

Callers 1

NewServerFunction · 0.95

Calls 3

CurrentFunction · 0.92
NextMethod · 0.80
HeartbeatOKMethod · 0.65

Tested by

no test coverage detected