diff --git a/src/main.rs b/src/main.rs index ab43c36..5e16f8f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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"}); diff --git a/src/mouth.rs b/src/mouth.rs index 5be4a2f..ec58ebd 100644 --- a/src/mouth.rs +++ b/src/mouth.rs @@ -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(); } }