1use std::sync::{
2 atomic::{self, AtomicBool},
3 Arc,
4};
5
6use serde_json::json;
7use warp::{reply::json, Rejection, Reply};
8
9pub(super) async fn health(running: Arc<AtomicBool>) -> Result<impl Reply, Rejection> {
12 if running.load(atomic::Ordering::Relaxed) {
13 Ok(warp::reply::with_status(
14 json(&json!({"ok": true})),
15 warp::http::StatusCode::OK,
16 ))
17 } else {
18 Ok(warp::reply::with_status(
19 json(&json!({"ok": false})),
20 warp::http::StatusCode::SERVICE_UNAVAILABLE,
21 ))
22 }
23}