This commit is contained in:
nic
2025-07-23 17:56:38 +03:00
parent a31b9310a2
commit 1c181d7e22
10 changed files with 196 additions and 44 deletions
+37
View File
@@ -0,0 +1,37 @@
package coordinator
import (
"sync"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
)
type Server struct {
router *echo.Echo
mu sync.RWMutex
coordinator *Coordinator
}
func NewServer() *Server {
return &Server{
router: echo.New(),
coordinator: NewCoordinator(),
}
}
func (s *Server) Configure() {
// Middleware
s.router.Use(middleware.Logger())
s.router.Use(middleware.Recover())
s.router.Use(middleware.CORS())
// Роуты
s.router.POST("/register", s.registerHandler)
s.router.GET("/peers", s.listPeers)
s.router.GET("/ws", s.websocketHandler)
}
func (s *Server) Run() error {
return s.router.Start(":8080")
}