osrs-prometheus-exporter/src/api/endpoints/worlds.rs

13 lines
No EOL
417 B
Rust

use axum::http::StatusCode;
use axum::response::IntoResponse;
use crate::collectors::player_count::get_player_count;
use super::convert_into_prom_metrics;
pub async fn get_worlds() -> impl IntoResponse {
let resp = match get_player_count().await {
Ok(r) => r,
Err(_) => return (StatusCode::INTERNAL_SERVER_ERROR, "Nope".to_string())
};
(StatusCode::OK, convert_into_prom_metrics(resp))
}