headless_lms_server/controllers/
healthz.rs

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