Add working API calls, fix warnings
All checks were successful
Build Crate / build (push) Successful in 7m16s

This commit is contained in:
2023-09-21 20:03:16 -04:00
parent 30b637dfef
commit 0a68829d6c
12 changed files with 147 additions and 69 deletions

20
src/handler/mod.rs Normal file
View File

@@ -0,0 +1,20 @@
use axum::{
extract::Json,
};
use crate::data::pool_match::{PoolMatch, PoolMatchList};
use std::thread;
use crate::data::store::DATA;
pub 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 store = DATA.lock().unwrap();
// Add the match
(*store).matches.pool_matches.push(pool_match);
// Return all pool matches
(*store).matches.clone()
}).join().unwrap();
Json(matches)
}