mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-19 03:22:53 +00:00
- 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)
52 lines
1.2 KiB
Go
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)
|
|
}
|