use axum::extract::State;
use axum::http::StatusCode;
use axum::response::IntoResponse;
use crate::server::AppState;
pub async fn metrics_analyze_handler(State(state): State<AppState>) -> axum::response::Response {
match state.metrics_cache().get().await {
Some(report) => axum::Json(report).into_response(),
None => StatusCode::SERVICE_UNAVAILABLE.into_response(),
}
}
pub async fn metrics_memory_handler(State(state): State<AppState>) -> axum::response::Response {
match state.memory_metrics_cache().get().await {
Some(report) => axum::Json(report).into_response(),
None => StatusCode::SERVICE_UNAVAILABLE.into_response(),
}
}
pub async fn metrics_search_handler(State(state): State<AppState>) -> axum::response::Response {
match state.search_metrics_cache().get().await {
Some(report) => axum::Json(report).into_response(),
None => StatusCode::SERVICE_UNAVAILABLE.into_response(),
}
}
pub async fn metrics_review_handler(State(state): State<AppState>) -> axum::response::Response {
match state.review_metrics_cache().get().await {
Some(report) => axum::Json(report).into_response(),
None => StatusCode::SERVICE_UNAVAILABLE.into_response(),
}
}
pub async fn metrics_mpm_handler(State(state): State<AppState>) -> axum::response::Response {
match state.mpm_metrics_cache().get().await {
Some(report) => axum::Json(report).into_response(),
None => StatusCode::SERVICE_UNAVAILABLE.into_response(),
}
}