Files
elo/src/handler/mod.rs
matkam7 0a68829d6c
All checks were successful
Build Crate / build (push) Successful in 7m16s
Add working API calls, fix warnings
2023-09-21 20:03:16 -04:00

21 lines
573 B
Rust

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)
}