add batch game info request

This commit is contained in:
2025-12-18 20:04:50 +01:00
parent f6d40b8f2e
commit d916014872
5 changed files with 206 additions and 40 deletions
+15 -1
View File
@@ -44,6 +44,19 @@ async fn get_game(
games.iter().find(|g| g.title == title).cloned()
}
#[post("/games/batch", data = "<req>")]
async fn get_games_batch(
_token: auth::Token,
game_list: &rocket::State<Mutex<Vec<Game>>>,
req: proto_utils::Proto<items::GetGameInfoRequest>,
) -> items::GameList {
let games = game_list.lock().await;
let req = req.into_inner();
let mut games = games.clone();
games.retain(|g| req.games.contains(&g.title));
items::GameList { games }
}
#[get("/games")]
async fn get_games(
_token: auth::Token,
@@ -319,7 +332,8 @@ async fn main() -> Result<(), std::io::Error> {
add_opinion,
remove_opinion,
add_game,
get_game_thumbnail
get_game_thumbnail,
get_games_batch
],
)
.mount(