cargo fmt

This commit is contained in:
Daan Boerlage 2023-04-06 18:31:40 +02:00
parent 6c37b2a0b0
commit 6612e020ff
Signed by: daan
GPG key ID: FCE070E1E4956606
12 changed files with 49 additions and 53 deletions

View file

@ -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")
}
}

View file

@ -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))
}
}

View file

@ -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))
}
}

View file

@ -1 +1 @@
pub mod endpoints;
pub mod endpoints;