watcher/server/proxy_svc.go
timerzz ba47d0a32a
Some checks failed
Build image / build (push) Failing after 20s
feat 抽出公共方法到common
2024-05-13 20:18:13 +08:00

29 lines
526 B
Go

package server
import (
"gitea.timerzz.com/kedaya_haitao/common/pkg/proxy"
"github.com/gofiber/fiber/v3"
)
type ProxySvc struct {
pool *proxy.ProxyPool
}
func NewProxySvc(pool *proxy.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,
})
}