Add card table loading

This commit is contained in:
2024-09-04 01:43:57 -04:00
parent 4674289473
commit 20d7f62f33
10 changed files with 93 additions and 61 deletions

View File

@@ -0,0 +1,18 @@
use std::path::Path;
use lazy_static::lazy_static;
use crate::server::server_state::ServerState;
use axum::{debug_handler, extract::State, http::StatusCode, Json};
use crate::models::card::CardTable;
lazy_static! {
static ref CARD_TABLE: CardTable =
CardTable::new_from_server_json(Path::new("./data/cardinfo.json"));
}
#[debug_handler]
pub async fn get_card_table(State(_): State<ServerState>) -> Result<Json<CardTable>, StatusCode> {
Ok(Json(CARD_TABLE.clone()))
}