feat: implement game listing API and integrate into frontend for display and selection.
This commit is contained in:
+16
-1
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user