Send json as string

This commit is contained in:
flyingscorpio@clevo 2022-12-02 22:56:16 +01:00
parent 2a5f6063b0
commit 073ecc88b4
2 changed files with 4 additions and 4 deletions

View file

@ -12,7 +12,7 @@ fn main() {
let listener = Ear::new();
let (stream, req) = listener.listen();
let sender = Mouth::new(stream);
let mut sender = Mouth::new(stream);
// let data: String = get_data(&req); // TODO: update type
// let json_data = transform_to_json(&data);
let json_data = serde_json::json!({"test": 200, "foo": "bar"});

View file

@ -1,4 +1,4 @@
use std::net::TcpStream;
use std::{net::TcpStream, io::Write};
use serde_json::Value;
@ -13,7 +13,7 @@ impl Mouth {
}
}
pub fn send_data(&self, data: Value) {
todo!();
pub fn send_data(&mut self, data: Value) {
self.stream.write_all(data.to_string().as_bytes()).unwrap();
}
}