osrs-prometheus-exporter/src/api/endpoints/stats.rs
2023-04-06 18:31:40 +02:00

14 lines
463 B
Rust

use super::convert_into_prom_metrics;
use crate::collectors::stats::get_player_stats;
use axum::extract::Path;
use axum::http::StatusCode;
use axum::response::IntoResponse;
pub async fn get_stats(Path(rsn): Path<String>) -> impl IntoResponse {
let resp = match get_player_stats(&rsn).await {
Ok(r) => r,
Err(_) => return (StatusCode::INTERNAL_SERVER_ERROR, "Nope".to_string()),
};
(StatusCode::OK, convert_into_prom_metrics(resp))
}