server: api/health.rs — GET /api/health returns uptime, session/agent counts
This commit is contained in:
parent
843c7bbbf2
commit
40bf516264
21
server/src/api/health.rs
Normal file
21
server/src/api/health.rs
Normal file
@ -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<Arc<AppState>>) -> 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))
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user