mirror of
https://codeberg.org/icewind/ugc-scaper.git
synced 2026-06-03 18:24:10 +02:00
map history api
This commit is contained in:
parent
62b8ff9b5c
commit
6eec064496
8 changed files with 30 additions and 10 deletions
|
|
@ -68,6 +68,7 @@ async fn main() -> MainResult {
|
|||
.route("/team/:id/roster", get(team_roster))
|
||||
.route("/team/:id/matches", get(team_matches))
|
||||
.route("/match/:id", get(match_page))
|
||||
.route("/maps/:format", get(map_history))
|
||||
.with_state(AppState::default());
|
||||
|
||||
// run it
|
||||
|
|
@ -180,3 +181,21 @@ async fn match_page(
|
|||
let response = state.client.match_info(id).await?;
|
||||
Ok(Json(response))
|
||||
}
|
||||
|
||||
#[instrument(skip(state))]
|
||||
async fn map_history(
|
||||
Path(format): Path<String>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<impl IntoResponse, ApiError> {
|
||||
let mode = match GameMode::from_str(&format) {
|
||||
Ok(mode) => mode,
|
||||
_ => {
|
||||
return Err(ApiError::Mallformared(format!(
|
||||
"invalid game mode {}",
|
||||
format
|
||||
)))
|
||||
}
|
||||
};
|
||||
let response = state.client.map_history(mode).await?;
|
||||
Ok(Json(response))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue