shift_proxy/routes/health.rs
1//! Health and stats endpoints.
2
3use crate::ProxyState;
4use axum::extract::State;
5use axum::response::Json;
6use serde_json::json;
7
8/// GET /health — proxy health check.
9///
10/// Returns a JSON object with service identity and version.
11/// The service string MUST match `HEALTH_SERVICE_ID` checked by
12/// the OpenCode plugin and `shift-ai proxy status`.
13pub async fn health_handler() -> Json<serde_json::Value> {
14 Json(json!({
15 "status": "ok",
16 "service": "@shift-preflight/runtime proxy",
17 "version": env!("CARGO_PKG_VERSION"),
18 }))
19}
20
21/// GET /stats — session statistics.
22pub async fn stats_handler(State(state): State<ProxyState>) -> Json<serde_json::Value> {
23 Json(state.session.to_json())
24}