Add base data structures for pool matches
Some checks failed
Build Crate / build (push) Failing after 4m29s

This commit is contained in:
2023-09-22 03:45:48 -04:00
parent 0a68829d6c
commit 30f3aa63d5
16 changed files with 148 additions and 123 deletions

2
src/server/mod.rs Normal file
View File

@@ -0,0 +1,2 @@
pub mod routes;

34
src/server/routes.rs Normal file
View File

@@ -0,0 +1,34 @@
// (Server only) Routes
use crate::{
data::{
pool_match::{PoolMatch, PoolMatchList},
store::DATA,
},
endpoints::MATCH,
};
use axum::{
extract::Json,
routing::{post, Router},
};
use std::thread;
pub fn register_routes(app: Router) -> Router {
let app = app.route(MATCH, post(post_match));
app
}
async fn post_match(Json(pool_match): Json<PoolMatch>) -> Json<PoolMatchList> {
// Update the store with the new match
let matches = thread::spawn(move || {
// Get the store
let mut data = DATA.lock().unwrap();
(*data).matches.add_pool_match(pool_match);
println!("{:?}", (*data).matches.pool_matches);
(*data).matches.clone()
})
.join()
.unwrap();
Json(matches)
}