cargo fmt
This commit is contained in:
parent
6c37b2a0b0
commit
6612e020ff
12 changed files with 49 additions and 53 deletions
|
@ -3,10 +3,7 @@ pub mod worlds;
|
|||
use crate::collectors::PromMetric;
|
||||
|
||||
fn convert_into_prom_metrics(data: Vec<impl PromMetric>) -> String {
|
||||
let metrics: Vec<String> = data
|
||||
.into_iter()
|
||||
.map(|w| w.to_metric_string())
|
||||
.collect();
|
||||
let metrics: Vec<String> = data.into_iter().map(|w| w.to_metric_string()).collect();
|
||||
|
||||
metrics.join("\n")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
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;
|
||||
use crate::collectors::stats::get_player_stats;
|
||||
use super::convert_into_prom_metrics;
|
||||
|
||||
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())
|
||||
Err(_) => return (StatusCode::INTERNAL_SERVER_ERROR, "Nope".to_string()),
|
||||
};
|
||||
|
||||
(StatusCode::OK, convert_into_prom_metrics(resp))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
use super::convert_into_prom_metrics;
|
||||
use crate::collectors::player_count::get_player_count;
|
||||
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())
|
||||
Err(_) => return (StatusCode::INTERNAL_SERVER_ERROR, "Nope".to_string()),
|
||||
};
|
||||
|
||||
(StatusCode::OK, convert_into_prom_metrics(resp))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
pub mod endpoints;
|
||||
pub mod endpoints;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue