49 lines
1.2 KiB
Go
49 lines
1.2 KiB
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/iliaivanov/spec-kit-remote/cmd/dev-pod-api/internal/model"
|
|
)
|
|
|
|
func (s *Server) handleClusterStatus(w http.ResponseWriter, r *http.Request) {
|
|
if RoleFromContext(r.Context()) != model.RoleAdmin {
|
|
writeError(w, http.StatusForbidden, "admin access required")
|
|
return
|
|
}
|
|
|
|
if s.Cluster == nil {
|
|
writeError(w, http.StatusServiceUnavailable, "cluster info not available")
|
|
return
|
|
}
|
|
|
|
status, err := s.Cluster.GetClusterStatus(r.Context())
|
|
if err != nil {
|
|
s.Logger.Error("failed to get cluster status", "error", err)
|
|
writeError(w, http.StatusInternalServerError, "failed to get cluster status")
|
|
return
|
|
}
|
|
|
|
writeJSON(w, http.StatusOK, status)
|
|
}
|
|
|
|
func (s *Server) handleCacheStats(w http.ResponseWriter, r *http.Request) {
|
|
if RoleFromContext(r.Context()) != model.RoleAdmin {
|
|
writeError(w, http.StatusForbidden, "admin access required")
|
|
return
|
|
}
|
|
|
|
if s.Cluster == nil {
|
|
writeError(w, http.StatusServiceUnavailable, "cluster info not available")
|
|
return
|
|
}
|
|
|
|
stats, err := s.Cluster.GetCacheStats(r.Context())
|
|
if err != nil {
|
|
s.Logger.Error("failed to get cache stats", "error", err)
|
|
writeError(w, http.StatusInternalServerError, "failed to get cache stats")
|
|
return
|
|
}
|
|
|
|
writeJSON(w, http.StatusOK, stats)
|
|
}
|