feat: Add frontend 401 unauthorized handling and update backend to async Rocket main.

This commit is contained in:
2025-12-03 12:16:49 +01:00
parent 926926f357
commit f9a4dd0851
4 changed files with 48 additions and 4 deletions
+10 -4
View File
@@ -1,3 +1,4 @@
use bincode::{Decode, Encode};
use rocket::fs::FileServer;
use std::sync::Mutex;
@@ -31,7 +32,7 @@ impl std::ops::Deref for User {
fn get_user(
_token: auth::Token,
user_list: &rocket::State<Mutex<Vec<User>>>,
name: String,
name: &str,
) -> Option<items::Person> {
let users = user_list.lock().unwrap();
users
@@ -55,7 +56,7 @@ fn get_users(
fn get_game(
_token: auth::Token,
game_list: &rocket::State<Vec<Game>>,
title: String,
title: &str,
) -> Option<items::Game> {
game_list.iter().find(|g| g.title == title).cloned()
}
@@ -102,8 +103,8 @@ async fn index_fallback() -> Option<rocket::fs::NamedFile> {
None
}
#[launch]
fn rocket() -> _ {
#[rocket::main]
async fn main() -> Result<(), std::io::Error> {
let mut game_list: Vec<Game> = Vec::new();
let mut user_list: Vec<User> = Vec::new();
@@ -139,4 +140,9 @@ fn rocket() -> _ {
)
.mount("/", routes![index_fallback])
.mount("/", FileServer::new("frontend/dist"))
.launch()
.await
.map_err(|e| std::io::Error::other(e.to_string()))?;
Ok(())
}