summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaweł Dybiec <pawel@dybiec.info>2022-12-25 21:13:52 +0000
committerPaweł Dybiec <pawel@dybiec.info>2022-12-25 21:13:52 +0000
commitde7e956c6e06c473613f254ca04e257af3e1da91 (patch)
tree4883c52b9e1b252d9777c370a6665cd145d34c12 /src
parentSet up ci (diff)
Parse json response from server
Diffstat (limited to 'src')
-rw-r--r--src/mattermost.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/mattermost.rs b/src/mattermost.rs
index 7742e3e..a062887 100644
--- a/src/mattermost.rs
+++ b/src/mattermost.rs
@@ -2,7 +2,7 @@ use anyhow::anyhow;
use async_tungstenite::{tokio::connect_async, tungstenite::Message};
use futures_util::{SinkExt, StreamExt};
use serde_json::json;
-use tracing::debug;
+use tracing::{debug, warn};
pub struct AuthData {
pub(crate) login: String,
pub(crate) password: String,
@@ -56,7 +56,22 @@ impl Client {
))
.await?;
while let Some(message) = ws_stream.next().await {
- debug!("{:?}", message);
+ match message {
+ Ok(message) => match message {
+ Message::Text(text) => {
+ let json: Result<serde_json::Value, _> = serde_json::from_str(&text);
+ match json {
+ Ok(json) => debug!("Got json {json}"),
+ Err(err) => warn!("Error while deserializing {err}"),
+ }
+ }
+ Message::Close(_) => break,
+ _ => {
+ debug!("Message {message:?}");
+ }
+ },
+ Err(err) => warn!("Error {err} while reading message"),
+ }
}
Ok(())
}