mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-13 15:46:53 +00:00
Begin implement bucket management & admin commands
This commit is contained in:
+9
-7
@@ -9,7 +9,7 @@ use futures::stream::futures_unordered::FuturesUnordered;
|
||||
use futures::stream::StreamExt;
|
||||
use futures_util::future::FutureExt;
|
||||
use hyper::client::{Client, HttpConnector};
|
||||
use hyper::{Body, Method, Request, StatusCode};
|
||||
use hyper::{Body, Method, Request};
|
||||
use tokio::sync::watch;
|
||||
|
||||
use crate::background::BackgroundRunner;
|
||||
@@ -228,12 +228,14 @@ impl RpcHttpClient {
|
||||
e
|
||||
})?;
|
||||
|
||||
if resp.status() == StatusCode::OK {
|
||||
let body = hyper::body::to_bytes(resp.into_body()).await?;
|
||||
let msg = rmp_serde::decode::from_read::<_, Result<M, String>>(body.into_buf())?;
|
||||
msg.map_err(Error::RPCError)
|
||||
} else {
|
||||
Err(Error::RPCError(format!("Status code {}", resp.status())))
|
||||
let status = resp.status();
|
||||
let body = hyper::body::to_bytes(resp.into_body()).await?;
|
||||
match rmp_serde::decode::from_read::<_, Result<M, String>>(body.into_buf()) {
|
||||
Err(e) =>
|
||||
Err(Error::RPCError(format!("Invalid reply"), status)),
|
||||
Ok(Err(e)) =>
|
||||
Err(Error::RPCError(e, status)),
|
||||
Ok(Ok(x)) => Ok(x),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user