//! Health check endpoint for the imks server. //! //! Returns JSON with server status, version, uptime, and connection counts //! sourced from live runtime state (session store + atomic counter). use actix_web::{HttpResponse, web}; use serde::Serialize; use crate::engine::session::SessionStore; use crate::telemetry; #[derive(Serialize)] struct HealthResponse { status: String, version: String, timestamp: String, uptime_secs: u64, connections_active: u64, sessions_count: usize, } /// GET /health — returns server health status with live connection metrics. pub async fn health_check(store: web::Data) -> HttpResponse { HttpResponse::Ok().json(HealthResponse { status: "healthy".into(), version: env!("CARGO_PKG_VERSION").into(), timestamp: chrono::Utc::now().to_rfc3339(), uptime_secs: telemetry::health::uptime_secs(), connections_active: telemetry::health::connections_active_count(), sessions_count: store.len(), }) }