headless_lms_server/controllers/
healthz.rs

1/*!
2Handlers for HTTP requests to `/api/v0/healthz`.
3*/
4
5use sqlx::Executor;
6
7use crate::controllers::main_frontend::status::system_health;
8use crate::prelude::*;
9
10/**
11GET `/api/v0/healthz` Tells whether the server is healthy (database connectivity).
12*/
13pub async fn healthz(pool: web::Data<PgPool>) -> ControllerResult<web::Json<bool>> {
14    let mut conn = pool.acquire().await?;
15    let token = skip_authorize();
16    let _res = conn.execute("SELECT 1").await?;
17    token.authorized_ok(web::Json(true))
18}
19
20pub fn _add_routes(cfg: &mut ServiceConfig) {
21    cfg.route("", web::get().to(healthz))
22        .route("/system", web::get().to(system_health));
23}