added CHANGE command

This commit is contained in:
2026-05-14 21:24:28 +01:00
parent a55053dc97
commit a18928c673
11 changed files with 82 additions and 11 deletions
+17 -2
View File
@@ -4,6 +4,7 @@ use crate::
// internal code
character,
// libraries
json,
HashMap,
Arc,
Mutex,
@@ -11,6 +12,7 @@ use crate::
mpsc::Sender,
info,
debug,
warn,
Serialize,
Deserialize,
};
@@ -60,8 +62,21 @@ pub async fn api_process
.and(characters_filter)
.map(|name: String, characters: Arc<Mutex<HashMap<String, character::Character>>>|
{
let map = characters.lock().unwrap(); // TODO eh
let reply = map.get(&name).unwrap(); // TODO eh
let characters = match characters.lock()
{
Ok(data) => data,
Err(poisoned) =>
{
warn!("Character Mutex is poisoned");
poisoned.into_inner()
},
};
let Some(reply) = characters.get(&name)
else
{
warn!("Client requested character that does not exist");
return warp::reply::json(&json!({"reply": "invalid character"}));
};
debug!("GET: name: {name}");
warp::reply::json(&reply)
}).boxed();