// proxy/stats.go package proxy import ( "encoding/json" "net/http" "siteproxy/cache" ) type StatsHandler struct { cache *cache.MemoryCache } func NewStatsHandler(cache *cache.MemoryCache) *StatsHandler { return &StatsHandler{cache: cache} } func (h *StatsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { stats := h.cache.GetStats() w.Header().Set("Content-Type", "application/json") w.Header().Set("Cache-Control", "no-cache, no-store, must-revalidate") encoder := json.NewEncoder(w) encoder.SetIndent("", " ") encoder.Encode(stats) }