Add Certificates page and Traefik API frontend client
This commit is contained in:
parent
9e4c612dcb
commit
7fc90524b5
40 changed files with 6585 additions and 359 deletions
|
|
@ -22,10 +22,10 @@ type Server struct {
|
|||
engine *gin.Engine
|
||||
config *config.Config
|
||||
db *database.DB
|
||||
traefik traefik.TraefikClient
|
||||
traefik traefik.TraefikAPI
|
||||
}
|
||||
|
||||
func NewServer(cfg *config.Config, db *database.DB, traefikClient traefik.TraefikClient) *Server {
|
||||
func NewServer(cfg *config.Config, db *database.DB, traefikAPI traefik.TraefikAPI) *Server {
|
||||
if !cfg.DevMode {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
|
@ -45,7 +45,10 @@ func NewServer(cfg *config.Config, db *database.DB, traefikClient traefik.Traefi
|
|||
"", // cookie domain
|
||||
!cfg.DevMode, // cookie secure - true in prod
|
||||
)
|
||||
configHandler := handlers.NewConfigHandler(traefikClient)
|
||||
// Legacy adapter for old ConfigHandler (which expects TraefikClient returning models)
|
||||
legacyTraefik := traefik.NewLegacyAdapter(traefikAPI)
|
||||
configHandler := handlers.NewConfigHandler(legacyTraefik)
|
||||
traefikHandler := handlers.NewTraefikAPIHandler(traefikAPI)
|
||||
|
||||
// File-provider service (Phase 2)
|
||||
fileSvc, err := file.NewService(cfg.ConfigDir, db.DB)
|
||||
|
|
@ -70,8 +73,9 @@ func NewServer(cfg *config.Config, db *database.DB, traefikClient traefik.Traefi
|
|||
authGroup := engine.Group("/api/auth")
|
||||
{
|
||||
authGroup.POST("/login", authHandler.Login)
|
||||
authGroup.POST("/logout", authMiddleware.RequireAuth(), authHandler.Logout)
|
||||
authGroup.POST("/logout", authMiddleware.RequireAuth(), authMiddleware.RequireCSRF(), authHandler.Logout)
|
||||
authGroup.GET("/me", authMiddleware.RequireAuth(), authHandler.Me)
|
||||
authGroup.GET("/csrf", authMiddleware.RequireAuth(), authHandler.GetCSRF)
|
||||
}
|
||||
|
||||
// Protected API endpoints
|
||||
|
|
@ -104,15 +108,18 @@ func NewServer(cfg *config.Config, db *database.DB, traefikClient traefik.Traefi
|
|||
configGroup.GET("/entrypoints", configHandler.ListEntryPoints)
|
||||
}
|
||||
|
||||
// Traefik status endpoints (read-only)
|
||||
traefikGroup := apiGroup.Group("/traefik")
|
||||
// Traefik status endpoints (read-only, new typed client with cache, viewer+)
|
||||
traefikGroup := engine.Group("/api/traefik")
|
||||
traefikGroup.Use(authMiddleware.RequireAuth())
|
||||
{
|
||||
traefikGroup.GET("/overview", configHandler.GetOverview)
|
||||
traefikGroup.GET("/routers", configHandler.ListRouters)
|
||||
traefikGroup.GET("/services", configHandler.ListServices)
|
||||
traefikGroup.GET("/middlewares", configHandler.ListMiddlewares)
|
||||
traefikGroup.GET("/certificates", configHandler.ListCertificates)
|
||||
traefikGroup.GET("/entrypoints", configHandler.ListEntryPoints)
|
||||
traefikGroup.GET("/health", traefikHandler.Health)
|
||||
traefikGroup.GET("/overview", traefikHandler.Overview)
|
||||
traefikGroup.GET("/entrypoints", traefikHandler.Entrypoints)
|
||||
traefikGroup.GET("/routers", traefikHandler.Routers)
|
||||
traefikGroup.GET("/services", traefikHandler.Services)
|
||||
traefikGroup.GET("/middlewares", traefikHandler.Middlewares)
|
||||
traefikGroup.GET("/providers", traefikHandler.Providers)
|
||||
traefikGroup.GET("/certificates", traefikHandler.Certificates)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -128,7 +135,7 @@ func NewServer(cfg *config.Config, db *database.DB, traefikClient traefik.Traefi
|
|||
engine: engine,
|
||||
config: cfg,
|
||||
db: db,
|
||||
traefik: traefikClient,
|
||||
traefik: traefikAPI,
|
||||
httpServer: &http.Server{
|
||||
Addr: cfg.Addr,
|
||||
Handler: engine,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue