build source
This commit is contained in:
commit
ee1fec43ed
4171 changed files with 1351288 additions and 0 deletions
49
internal/api/cluster.go
Normal file
49
internal/api/cluster.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue