separate match data api from match log api
This commit is contained in:
parent
7d743bdbbb
commit
c7f4da07c1
2 changed files with 15 additions and 1 deletions
|
@ -53,7 +53,11 @@ pub async fn api() -> Router {
|
|||
"/matches",
|
||||
get(routes::matches::list_matches).post(routes::matches::play_match),
|
||||
)
|
||||
.route("/matches/:match_id", get(routes::matches::get_match_log))
|
||||
.route("/matches/:match_id", get(routes::matches::get_match_data))
|
||||
.route(
|
||||
"/matches/:match_id/log",
|
||||
get(routes::matches::get_match_log),
|
||||
)
|
||||
.route("/submit_bot", post(routes::demo::submit_bot))
|
||||
.layer(AddExtensionLayer::new(pool));
|
||||
api
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue