package handlers import ( "github.com/gin-gonic/gin" "git.netcell-it.de/projekte/edgeguard-native/internal/handlers/response" "git.netcell-it.de/projekte/edgeguard-native/internal/services/setup" ) // SetupHandler exposes the first-run wizard endpoints. Both endpoints // are mounted before SetupGate so they remain reachable while the API // is in setup mode. type SetupHandler struct { Store *setup.Store } func NewSetupHandler(store *setup.Store) *SetupHandler { return &SetupHandler{Store: store} } func (h *SetupHandler) Register(rg *gin.RouterGroup) { g := rg.Group("/setup") g.GET("/status", h.Status) g.POST("/complete", h.Complete) } // Status returns just the public bits of the setup state: whether // it's done and (if so) the configured admin_email + fqdn. Never // exposes the password hash. func (h *SetupHandler) Status(c *gin.Context) { st, err := h.Store.Load() if err != nil { response.Internal(c, err) return } response.OK(c, gin.H{ "completed": st.Completed, "admin_email": st.AdminEmail, "fqdn": st.FQDN, }) } func (h *SetupHandler) Complete(c *gin.Context) { var req setup.Request if err := c.ShouldBindJSON(&req); err != nil { response.BadRequest(c, err) return } st, err := h.Store.Complete(req) if err != nil { response.BadRequest(c, err) return } response.OK(c, gin.H{ "completed": st.Completed, "admin_email": st.AdminEmail, "fqdn": st.FQDN, }) }