diff options
Diffstat (limited to 'src/api.rs')
-rw-r--r-- | src/api.rs | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -3,11 +3,11 @@ use std::collections::HashMap; use axum::{extract::State, response::IntoResponse, Json}; use serde::{Deserialize, Serialize}; -use crate::{service::Services, Status}; +use crate::{service::ServiceHandles, Status}; pub mod services; -pub fn router() -> axum::Router<Services> { +pub fn router() -> axum::Router<ServiceHandles> { use axum::routing::get; axum::Router::new() @@ -37,11 +37,11 @@ impl IntoResponse for Health { } } -pub async fn healthcheck(State(services): State<Services>) -> Health { - let checks = match services.check().await { - Ok(c) => c, - Err(err) => return err.into(), - }; +pub async fn healthcheck(State(services): State<ServiceHandles>) -> Health { + let checks = services + .iter() + .map(|(name, srv)| (name.clone(), srv.status())) + .collect::<HashMap<String, Status>>(); let status = match checks .values() |