1use axum::{
2 extract::State,
3 response::{IntoResponse, Response},
4 Json,
5};
6use serde_json::{json, Value};
7use soma_http_api::probe::{liveness_response, readiness_response};
8
9use crate::ApiState;
10
11pub async fn health() -> impl IntoResponse {
13 tracing::debug!("health probe");
14 liveness_response()
15}
16
17pub async fn readyz(State(state): State<ApiState>) -> Response {
23 let result = state.application().readiness().await;
24 if let Err(error) = &result {
25 tracing::warn!(%error, "readiness probe failed");
26 }
27 readiness_response(result)
28}
29
30pub async fn status(State(state): State<ApiState>) -> Response {
32 Json(status_body(state.server_name())).into_response()
33}
34
35fn status_body(server_name: &str) -> Value {
36 json!({
37 "status": "ok",
38 "server": server_name,
39 "version": env!("CARGO_PKG_VERSION"),
40 "transport": "http",
41 })
42}
43
44#[cfg(test)]
45#[path = "probes_tests.rs"]
46mod tests;