feat(stats): gateway request stats/audit API + polish scratch sort animations (link chain, reset, cleanup)

This commit is contained in:
root
2026-08-08 13:34:40 +08:00
parent 31eefe9288
commit dec03238dd
5 changed files with 646 additions and 131 deletions

View File

@ -113,4 +113,14 @@ func (g *Gateway) handleSourcesAPI(w http.ResponseWriter, r *http.Request) {
default:
writeError(w, http.StatusMethodNotAllowed, "method_not_allowed", "")
}
}
}
// handleStatsAPI returns per-key / per-model / per-source usage aggregates and
// the recent request audit trail.
func (g *Gateway) handleStatsAPI(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodGet {
writeError(w, http.StatusMethodNotAllowed, "method_not_allowed", "use GET")
return
}
limit := 500
writeJSON(w, http.StatusOK, g.stats.Snapshot(limit))
}