Adding websocket blocking.

This commit is contained in:
Dessalines 2020-04-21 17:57:20 -04:00
parent 3f6a4096f8
commit 14fb5f57c4

View file

@ -896,10 +896,18 @@ where
let data = data.to_string(); let data = data.to_string();
let op2 = op.clone(); let op2 = op.clone();
let fut = async move { let fut = async move {
let parsed_data: Data = serde_json::from_str(&data)?; actix_web::web::block(move || {
let res = Oper::new(parsed_data).perform(pool, Some(ws_info))?; let parsed_data: Data = serde_json::from_str(&data)?;
to_json_string(&op, &res) let res = Oper::new(parsed_data).perform(pool, Some(ws_info))?;
to_json_string(&op, &res)
})
.await
.map_err(|e| match e {
actix_web::error::BlockingError::Error(e) => e,
_ => APIError::err("Operation canceled").into(),
})
}; };
match op2 { match op2 {