Files
telecom-platform/apps/api-server/internal/handlers/platform_config.go
T
nutcas3 d99109386b feat: Refactor platform.go to extract domain handlers into separate files and retain only shared helpers
- Add package documentation mapping handler files to domains (services/monitoring/deployments/plugins/automation/config/chaos/billing)
- Remove gorm.io/gorm, models, monitoring, and services package imports
- Remove ServicesHandler struct and all methods (List/Get/Restart/Start/Stop/Scale/Logs/Health/PodStatus/Events)
- Remove MonitoringHandler struct and all methods (Metrics/Alerts/Health/Logs)
2026-04-24 08:54:23 +03:00

52 lines
1.2 KiB
Go

package handlers
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/nutcas3/telecom-platform/apps/api-server/internal/services"
)
// ConfigHandler exposes runtime config read/write/validate endpoints.
type ConfigHandler struct {
svc *services.ConfigStoreService
}
// NewConfigHandler constructs a ConfigHandler.
func NewConfigHandler(svc *services.ConfigStoreService) *ConfigHandler {
return &ConfigHandler{svc: svc}
}
func (h *ConfigHandler) Get(c *gin.Context) {
entries, err := h.svc.List(c.Request.Context(), c.Query("section"))
if err != nil {
serverError(c, err)
return
}
c.JSON(http.StatusOK, gin.H{"entries": entries, "total": len(entries)})
}
func (h *ConfigHandler) Update(c *gin.Context) {
var in services.UpsertConfigInput
if err := c.ShouldBindJSON(&in); err != nil {
badRequest(c, err)
return
}
entry, err := h.svc.Upsert(c.Request.Context(), in)
if err != nil {
serverError(c, err)
return
}
c.JSON(http.StatusOK, entry)
}
func (h *ConfigHandler) Validate(c *gin.Context) {
res, err := h.svc.Validate(c.Request.Context(), c.Query("section"))
if err != nil {
serverError(c, err)
return
}
c.JSON(http.StatusOK, res)
}