add batch game info request
This commit is contained in:
+15
-1
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user