Add working API calls, fix warnings
All checks were successful
Build Crate / build (push) Successful in 7m16s
All checks were successful
Build Crate / build (push) Successful in 7m16s
This commit is contained in:
20
src/handler/mod.rs
Normal file
20
src/handler/mod.rs
Normal 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)
|
||||
}
|
||||
Reference in New Issue
Block a user