aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/src/routes/matches.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-02-12 23:52:45 +0100
committerIlion Beyst <ilion.beyst@gmail.com>2022-02-12 23:52:45 +0100
commitc7f4da07c1bb3b8a52a596e7c2573c7bf3ce7b79 (patch)
treeda43f0d3f443446ceb59e661a7f981f9a3c05cd6 /planetwars-server/src/routes/matches.rs
parent7d743bdbbbf3112fa36c146b6c07a5b09d1388f8 (diff)
downloadplanetwars.dev-c7f4da07c1bb3b8a52a596e7c2573c7bf3ce7b79.tar.xz
planetwars.dev-c7f4da07c1bb3b8a52a596e7c2573c7bf3ce7b79.zip
separate match data api from match log api
Diffstat (limited to 'planetwars-server/src/routes/matches.rs')
-rw-r--r--planetwars-server/src/routes/matches.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/planetwars-server/src/routes/matches.rs b/planetwars-server/src/routes/matches.rs
index 089bd71..44c8607 100644
--- a/planetwars-server/src/routes/matches.rs
+++ b/planetwars-server/src/routes/matches.rs
@@ -136,6 +136,16 @@ pub struct BotConfig {
pub build_command: Option<String>,
}
+pub async fn get_match_data(
+ Path(match_id): Path<i32>,
+ conn: DatabaseConnection,
+) -> Result<Json<ApiMatch>, StatusCode> {
+ let match_data = matches::find_match(match_id, &conn)
+ .map_err(|_| StatusCode::NOT_FOUND)
+ .map(|data| match_data_to_api(data))?;
+ Ok(Json(match_data))
+}
+
pub async fn get_match_log(
Path(match_id): Path<i32>,
conn: DatabaseConnection,