diff options
Diffstat (limited to 'planetwars-server/src/routes')
-rw-r--r-- | planetwars-server/src/routes/bots.rs | 6 | ||||
-rw-r--r-- | planetwars-server/src/routes/matches.rs | 12 | ||||
-rw-r--r-- | planetwars-server/src/routes/mod.rs | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/planetwars-server/src/routes/bots.rs b/planetwars-server/src/routes/bots.rs index f722e52..8327443 100644 --- a/planetwars-server/src/routes/bots.rs +++ b/planetwars-server/src/routes/bots.rs @@ -58,6 +58,12 @@ pub async fn get_my_bots( .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) } +pub async fn list_bots(conn: DatabaseConnection) -> Result<Json<Vec<Bot>>, StatusCode> { + bots::find_all_bots(&conn) + .map(Json) + .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR) +} + // TODO: currently this only implements the happy flow pub async fn upload_code_multipart( conn: DatabaseConnection, diff --git a/planetwars-server/src/routes/matches.rs b/planetwars-server/src/routes/matches.rs new file mode 100644 index 0000000..7eca6ab --- /dev/null +++ b/planetwars-server/src/routes/matches.rs @@ -0,0 +1,12 @@ +use axum::Json; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Debug)] +pub struct MatchParams { + // Just bot ids for now + players: Vec<i32>, +} + +pub async fn play_match(params: Json<MatchParams>) { + println!("start match: {:#?}", params); +} diff --git a/planetwars-server/src/routes/mod.rs b/planetwars-server/src/routes/mod.rs index 718d7ef..c2d3c44 100644 --- a/planetwars-server/src/routes/mod.rs +++ b/planetwars-server/src/routes/mod.rs @@ -1,2 +1,3 @@ pub mod bots; +pub mod matches; pub mod users; |