iota_rest_kv/routes/
health.rs1use axum::{Json, extract::State, response::IntoResponse};
5use serde::Serialize;
6
7use crate::{kv_store_client::AwsStatus, types::SharedKvStoreClient};
8
9bin_version::bin_version!();
10
11#[derive(Serialize)]
13pub struct HealthResponse {
14 pub version: String,
16 pub git_hash: String,
18 pub uptime: String,
20 pub aws_status: AwsStatus,
22}
23
24pub async fn health(State(kv_store_client): State<SharedKvStoreClient>) -> impl IntoResponse {
29 let aws_status = kv_store_client.get_aws_health().await;
30
31 let response = HealthResponse {
32 version: VERSION.to_owned(),
33 git_hash: GIT_REVISION.to_owned(),
34 uptime: format!("{:?}", kv_store_client.get_uptime()),
35 aws_status,
36 };
37
38 Json(response)
39}