Send json as string
This commit is contained in:
parent
2a5f6063b0
commit
073ecc88b4
2 changed files with 4 additions and 4 deletions
|
@ -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"});
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue