Management endpoint that returns running counters for total requests, upstream token usage, and per-sender email-filter activity. Only reachable from loopback peers; streaming (SSE) responses are not included in token totals (see `handle_request`).
(
State(state): State<AppState>,
ConnectInfo(peer): ConnectInfo<SocketAddr>,
)
| 492 | /// reachable from loopback peers; streaming (SSE) responses are not |
| 493 | /// included in token totals (see `handle_request`). |
| 494 | async fn handle_stats( |
| 495 | State(state): State<AppState>, |
| 496 | ConnectInfo(peer): ConnectInfo<SocketAddr>, |
| 497 | ) -> Result<Response, Response> { |
| 498 | if !peer.ip().is_loopback() { |
| 499 | warn!( |
| 500 | peer = %peer, |
| 501 | "Non-loopback client tried to hit /admin/stats" |
| 502 | ); |
| 503 | return Err(error_response( |
| 504 | StatusCode::FORBIDDEN, |
| 505 | "stats endpoint is loopback-only", |
| 506 | )); |
| 507 | } |
| 508 | Ok(axum::Json(state.stats.snapshot()).into_response()) |
| 509 | } |
| 510 | |
| 511 | async fn handle_request( |
| 512 | State(state): State<AppState>, |
nothing calls this directly
no test coverage detected