更新 proxy/stats.go

This commit is contained in:
XOF
2025-12-15 02:44:03 +08:00
parent 1bc606ee00
commit 8305c2f2fe

View File

@@ -17,13 +17,12 @@ func NewStatsHandler(cache *cache.MemoryCache) *StatsHandler {
} }
func (h *StatsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h *StatsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
entries, size := h.cache.Stats() stats := h.cache.GetStats()
stats := map[string]interface{}{
"entries": entries,
"size": size,
}
w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(stats) w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate")
encoder := json.NewEncoder(w)
encoder.SetIndent("", " ")
encoder.Encode(stats)
} }