aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api/api_server.rs16
-rw-r--r--src/api/helpers.rs10
-rw-r--r--src/api/lib.rs2
3 files changed, 15 insertions, 13 deletions
diff --git a/src/api/api_server.rs b/src/api/api_server.rs
index cdf8fa78..3f65da26 100644
--- a/src/api/api_server.rs
+++ b/src/api/api_server.rs
@@ -1,7 +1,7 @@
use std::collections::HashMap;
+use std::convert::Infallible;
use std::net::SocketAddr;
use std::sync::Arc;
-use std::convert::Infallible;
use futures::future::Future;
use hyper::server::conn::AddrStream;
@@ -15,12 +15,12 @@ use garage_model::garage::Garage;
use crate::error::*;
use crate::signature::check_signature;
+use crate::helpers::*;
use crate::s3_copy::*;
use crate::s3_delete::*;
use crate::s3_get::*;
use crate::s3_list::*;
use crate::s3_put::*;
-use crate::helpers::*;
pub async fn run_api_server(
garage: Arc<Garage>,
@@ -48,16 +48,18 @@ pub async fn run_api_server(
Ok(())
}
-async fn handler(garage: Arc<Garage>, req: Request<Body>, client_addr: SocketAddr) -> Result<Response<Body>, Infallible> {
+async fn handler(
+ garage: Arc<Garage>,
+ req: Request<Body>,
+ client_addr: SocketAddr,
+) -> Result<Response<Body>, Infallible> {
info!("{} {} {}", client_addr, req.method(), req.uri());
debug!("{:?}", req);
- controller(garage, req)
- .await
- .make_infallible()
+ controller(garage, req).await.make_infallible()
}
-async fn controller(garage: Arc<Garage>, req: Request<Body>) -> Result<Response<Body>, GarageError> {
+async fn controller(garage: Arc<Garage>, req: Request<Body>) -> Result<Response<Body>, Error> {
let path = req.uri().path().to_string();
let path = percent_encoding::percent_decode_str(&path).decode_utf8()?;
diff --git a/src/api/helpers.rs b/src/api/helpers.rs
index f4d91788..b762bd3f 100644
--- a/src/api/helpers.rs
+++ b/src/api/helpers.rs
@@ -1,20 +1,20 @@
+use hyper::{Body, Response};
use std::convert::Infallible;
use std::net::SocketAddr;
-use hyper::{Body, Response};
-use garage_util::error::Error as GarageError;
+use crate::error::*;
pub trait InfallibleResult {
fn make_infallible(self) -> Result<Response<Body>, Infallible>;
}
-impl InfallibleResult for Result<Response<Body>, GarageError> {
+impl InfallibleResult for Result<Response<Body>, Error> {
fn make_infallible(self) -> Result<Response<Body>, Infallible> {
match self {
Ok(x) => {
- debug!("{} {:?}", x.status(), x.headers());
+ debug!("{} {:?}", x.status(), x.headers());
Ok(x)
- },
+ }
Err(e) => {
let body: Body = Body::from(format!("{}\n", e));
let mut http_error = Response::new(body);
diff --git a/src/api/lib.rs b/src/api/lib.rs
index 7327354f..0eb64918 100644
--- a/src/api/lib.rs
+++ b/src/api/lib.rs
@@ -8,9 +8,9 @@ pub mod encoding;
pub mod api_server;
pub mod signature;
+pub mod helpers;
pub mod s3_copy;
pub mod s3_delete;
pub mod s3_get;
pub mod s3_list;
pub mod s3_put;
-pub mod helpers;