aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/routes/matches.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-07-16 21:22:03 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-07-16 21:22:03 +0200
commitd13d131130ab53fb8ee7d49d2b40718622a4ab11 (patch)
tree7966ffc15804369d43c6a0cdba7e7505fea512d3 /planetwars-server/src/routes/matches.rs
parentec5c91d37b46cb3cec4878176469c66d2304dadd (diff)
downloadplanetwars.dev-d13d131130ab53fb8ee7d49d2b40718622a4ab11.tar.xz
planetwars.dev-d13d131130ab53fb8ee7d49d2b40718622a4ab11.zip
move storage paths to GlobalConfig
Diffstat (limited to 'planetwars-server/src/routes/matches.rs')
-rw-r--r--planetwars-server/src/routes/matches.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/planetwars-server/src/routes/matches.rs b/planetwars-server/src/routes/matches.rs
index f33a5f1..a980daa 100644
--- a/planetwars-server/src/routes/matches.rs
+++ b/planetwars-server/src/routes/matches.rs
@@ -1,11 +1,11 @@
-use axum::{extract::Path, Json};
+use axum::{extract::Path, Extension, Json};
use hyper::StatusCode;
use serde::{Deserialize, Serialize};
-use std::path::PathBuf;
+use std::{path::PathBuf, sync::Arc};
use crate::{
db::matches::{self, MatchState},
- DatabaseConnection, MATCHES_DIR,
+ DatabaseConnection, GlobalConfig,
};
#[derive(Serialize, Deserialize)]
@@ -59,10 +59,11 @@ pub async fn get_match_data(
pub async fn get_match_log(
Path(match_id): Path<i32>,
conn: DatabaseConnection,
+ Extension(config): Extension<Arc<GlobalConfig>>,
) -> Result<Vec<u8>, StatusCode> {
let match_base =
matches::find_match_base(match_id, &conn).map_err(|_| StatusCode::NOT_FOUND)?;
- let log_path = PathBuf::from(MATCHES_DIR).join(&match_base.log_path);
+ let log_path = PathBuf::from(&config.match_logs_directory).join(&match_base.log_path);
let log_contents = std::fs::read(log_path).map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
Ok(log_contents)
}