added CHANGE command
This commit is contained in:
+17
-2
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user