feat: implement game listing API and integrate into frontend for display and selection.

This commit is contained in:
2025-12-03 19:01:38 +01:00
parent e192829fdd
commit 0c3c9e61b6
5 changed files with 204 additions and 8 deletions
+16 -1
View File
@@ -92,6 +92,14 @@ fn get_game(
games.iter().find(|g| g.title == title).cloned()
}
#[get("/games")]
fn get_games(_token: auth::Token, game_list: &rocket::State<Mutex<Vec<Game>>>) -> items::GameList {
let games = game_list.lock().unwrap();
items::GameList {
games: games.clone(),
}
}
#[post("/game", data = "<game>")]
fn add_game(
_token: auth::Token,
@@ -203,7 +211,14 @@ async fn main() -> Result<(), std::io::Error> {
.manage(Mutex::new(game_list))
.mount(
"/api",
routes![get_users, get_user, get_game, add_opinion, add_game],
routes![
get_users,
get_user,
get_game,
get_games,
add_opinion,
add_game
],
)
.mount(
"/auth",