watcher/server/proxy_svc.go
timerzz 4b9085fe95
All checks were successful
Build image / build (push) Successful in 1m15s
feat 展示proxy信息,保存pid
2024-04-12 15:29:43 +08:00

29 lines
505 B
Go

package server
import (
"github.com/gofiber/fiber/v3"
pool "haitao_watcher/pkg/pools"
)
type ProxySvc struct {
pool *pool.ProxyPool
}
func NewProxySvc(pool *pool.ProxyPool) *ProxySvc {
return &ProxySvc{
pool: pool,
}
}
func (s *ProxySvc) RegistryRouter(r fiber.Router) {
r.Get("proxies/status", s.GetStatusInfo)
}
func (s *ProxySvc) GetStatusInfo(ctx fiber.Ctx) error {
list, updated := s.pool.Status()
return ctx.JSON(map[string]interface{}{
"list": list,
"updated": updated,
})
}