mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-18 17:55:12 +00:00
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)
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user