diff options
author | Alex Auvolat <alex@adnab.me> | 2020-04-09 18:43:53 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-04-09 18:43:53 +0200 |
commit | 1d786c2c663ac6f6e3e3ef52accd6e9eca049988 (patch) | |
tree | 813720a682fe7cf4947129020d73ccf4797d0c3a /src/rpc_server.rs | |
parent | 101444abb3967770ec378ee09f24eb2845dc091d (diff) | |
download | garage-1d786c2c663ac6f6e3e3ef52accd6e9eca049988.tar.gz garage-1d786c2c663ac6f6e3e3ef52accd6e9eca049988.zip |
Something works
Diffstat (limited to 'src/rpc_server.rs')
-rw-r--r-- | src/rpc_server.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/rpc_server.rs b/src/rpc_server.rs index 0ac26141..d3bc174d 100644 --- a/src/rpc_server.rs +++ b/src/rpc_server.rs @@ -8,6 +8,7 @@ use hyper::{Body, Method, Request, Response, Server, StatusCode}; use futures::future::Future; use crate::error::Error; +use crate::data::rmp_to_vec_all_named; use crate::proto::Message; use crate::server::Garage; @@ -28,7 +29,7 @@ async fn handler(garage: Arc<Garage>, req: Request<Body>, addr: SocketAddr) -> R let whole_body = hyper::body::to_bytes(req.into_body()).await?; let msg = rmp_serde::decode::from_read::<_, Message>(whole_body.into_buf())?; - eprintln!("RPC from {}: {:?}", addr, msg); + eprintln!("RPC from {}: {}", addr, serde_json::to_string(&msg)?); let sys = garage.system.clone(); let resp = err_to_msg(match &msg { @@ -49,8 +50,10 @@ async fn handler(garage: Arc<Garage>, req: Request<Body>, addr: SocketAddr) -> R _ => Ok(Message::Error(format!("Unexpected message: {:?}", msg))), }); + eprintln!("reply to {}: {}", addr, serde_json::to_string(&resp)?); + Ok(Response::new(Body::from( - rmp_serde::encode::to_vec_named(&resp)? + rmp_to_vec_all_named(&resp)? ))) } |