feat: add first page with auth and containers list and agents
This commit is contained in:
35
server/internal/api/router.go
Normal file
35
server/internal/api/router.go
Normal file
@ -0,0 +1,35 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
)
|
||||
|
||||
func NewRouter(h *Handler) http.Handler {
|
||||
r := chi.NewRouter()
|
||||
r.Use(middleware.Logger)
|
||||
r.Use(middleware.Recoverer)
|
||||
r.Use(middleware.RealIP)
|
||||
|
||||
r.Route("/api/v1", func(r chi.Router) {
|
||||
r.Post("/auth/login", h.Login)
|
||||
|
||||
r.Group(func(r chi.Router) {
|
||||
r.Use(requireJWT)
|
||||
r.Post("/auth/change-password", h.ChangePassword)
|
||||
r.Get("/agents", h.ListAgents)
|
||||
r.Post("/agents/token", h.CreateAgentToken)
|
||||
r.Patch("/agents/{agentID}", h.UpdateAgent)
|
||||
r.Get("/containers", h.ListContainers)
|
||||
r.Post("/agents/{agentID}/containers/{containerID}/action", h.ContainerAction)
|
||||
r.Get("/agents/{agentID}/containers/{containerID}/logs", h.LogsWS)
|
||||
r.Get("/events", h.EventsWS)
|
||||
})
|
||||
})
|
||||
|
||||
r.Handle("/*", http.FileServer(http.Dir("./web/dist")))
|
||||
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user