26 lines
761 B
Go
26 lines
761 B
Go
package api
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
// handleStatsDashboard GET /console/api/stats/dashboard-url
|
|
// Возвращает публичный URL дашборда Grafana для текущего namespace пользователя.
|
|
// Если аналитика не настроена — возвращает {"url":""}.
|
|
func (s *Server) handleStatsDashboard(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
writeJSONError(w, http.StatusMethodNotAllowed, "method not allowed")
|
|
return
|
|
}
|
|
|
|
ns := s.userNS(r)
|
|
url := s.stats.DashboardURL(r.Context(), ns)
|
|
|
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
|
_ = json.NewEncoder(w).Encode(map[string]any{
|
|
"url": url,
|
|
"namespace": ns,
|
|
})
|
|
}
|