diff --git a/server/src/api/health.rs b/server/src/api/health.rs new file mode 100644 index 0000000..f81ed05 --- /dev/null +++ b/server/src/api/health.rs @@ -0,0 +1,21 @@ +use actix_web::{web, HttpResponse}; +use std::sync::Arc; + +use crate::models::{ApiResponse, HealthInfo}; +use crate::state::AppState; + +/// `GET /api/health` +/// +/// Returns server uptime, active sessions, connected agents and version. +pub async fn health(state: web::Data>) -> HttpResponse { + let uptime = state.started_at.elapsed().as_secs(); + let (sessions, agents) = state.stats(); + let info = HealthInfo { + status: "ok".into(), + uptime_secs: uptime, + active_sessions: sessions, + connected_agents: agents, + version: env!("CARGO_PKG_VERSION").into(), + }; + HttpResponse::Ok().json(ApiResponse::ok(info)) +}