aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2024-02-07 14:45:52 +0100
committerAlex Auvolat <alex@adnab.me>2024-02-07 14:45:52 +0100
commite524e7a30d4d81c84f1c110017ad972dc5617bf6 (patch)
tree446b074e199c47c109fa517e5ec6717c2fe15b5f
parentfe48d60d2b63a9914297558bd5dbccae8d96c947 (diff)
downloadgarage-e524e7a30d4d81c84f1c110017ad972dc5617bf6.tar.gz
garage-e524e7a30d4d81c84f1c110017ad972dc5617bf6.zip
[dep-upgrade-202402] rename BytesBody into ErrorBody for clarity
-rw-r--r--Cargo.toml2
-rw-r--r--src/api/admin/error.rs6
-rw-r--r--src/api/generic_server.rs4
-rw-r--r--src/api/helpers.rs6
-rw-r--r--src/api/k2v/error.rs4
-rw-r--r--src/api/s3/error.rs4
6 files changed, 13 insertions, 13 deletions
diff --git a/Cargo.toml b/Cargo.toml
index b47f2e33..1daa9f8e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -98,7 +98,7 @@ httpdate = "1.0"
http-range = "0.1"
http-body-util = "0.1"
hyper = { version = "1.0", features = ["server", "http1"] }
-hyper-util = { verion = "0.1", features = [ "full" ]}
+hyper-util = { version = "0.1", features = [ "full" ] }
multer = "3.0"
percent-encoding = "2.2"
roxmltree = "0.19"
diff --git a/src/api/admin/error.rs b/src/api/admin/error.rs
index 011c903f..2668b42d 100644
--- a/src/api/admin/error.rs
+++ b/src/api/admin/error.rs
@@ -7,7 +7,7 @@ pub use garage_model::helper::error::Error as HelperError;
use crate::common_error::CommonError;
pub use crate::common_error::{CommonErrorDerivative, OkOrBadRequest, OkOrInternalError};
use crate::generic_server::ApiError;
-use crate::helpers::{BytesBody, CustomApiErrorBody};
+use crate::helpers::*;
/// Errors of this crate
#[derive(Debug, Error)]
@@ -65,7 +65,7 @@ impl ApiError for Error {
header_map.append(header::CONTENT_TYPE, "application/json".parse().unwrap());
}
- fn http_body(&self, garage_region: &str, path: &str) -> BytesBody {
+ fn http_body(&self, garage_region: &str, path: &str) -> ErrorBody {
let error = CustomApiErrorBody {
code: self.code().to_string(),
message: format!("{}", self),
@@ -81,6 +81,6 @@ impl ApiError for Error {
"#
.into()
});
- BytesBody::from(bytes::Bytes::from(error_str.into_bytes()))
+ error_body(error_str)
}
}
diff --git a/src/api/generic_server.rs b/src/api/generic_server.rs
index e3005f8a..20d70833 100644
--- a/src/api/generic_server.rs
+++ b/src/api/generic_server.rs
@@ -30,7 +30,7 @@ use garage_util::forwarded_headers;
use garage_util::metrics::{gen_trace_id, RecordDuration};
use garage_util::socket_address::UnixOrTCPSocketAddress;
-use crate::helpers::{BoxBody, BytesBody};
+use crate::helpers::{BoxBody, ErrorBody};
pub(crate) trait ApiEndpoint: Send + Sync + 'static {
fn name(&self) -> &'static str;
@@ -40,7 +40,7 @@ pub(crate) trait ApiEndpoint: Send + Sync + 'static {
pub trait ApiError: std::error::Error + Send + Sync + 'static {
fn http_status_code(&self) -> StatusCode;
fn add_http_headers(&self, header_map: &mut HeaderMap<HeaderValue>);
- fn http_body(&self, garage_region: &str, path: &str) -> BytesBody;
+ fn http_body(&self, garage_region: &str, path: &str) -> ErrorBody;
}
#[async_trait]
diff --git a/src/api/helpers.rs b/src/api/helpers.rs
index 57aa1ea1..66f4c465 100644
--- a/src/api/helpers.rs
+++ b/src/api/helpers.rs
@@ -144,7 +144,7 @@ pub fn key_after_prefix(pfx: &str) -> Option<String> {
// =============== body helpers =================
pub type EmptyBody = http_body_util::Empty<bytes::Bytes>;
-pub type BytesBody = FullBody<bytes::Bytes>;
+pub type ErrorBody = FullBody<bytes::Bytes>;
pub type BoxBody<E> = http_body_util::combinators::BoxBody<bytes::Bytes, E>;
pub fn string_body<E>(s: String) -> BoxBody<E> {
@@ -156,8 +156,8 @@ pub fn bytes_body<E>(b: bytes::Bytes) -> BoxBody<E> {
pub fn empty_body<E>() -> BoxBody<E> {
BoxBody::new(http_body_util::Empty::new().map_err(|_| unreachable!()))
}
-pub fn string_bytes_body(s: String) -> BytesBody {
- BytesBody::from(bytes::Bytes::from(s.into_bytes()))
+pub fn error_body(s: String) -> ErrorBody {
+ ErrorBody::from(bytes::Bytes::from(s.into_bytes()))
}
pub async fn parse_json_body<T, B, E>(req: Request<B>) -> Result<T, E>
diff --git a/src/api/k2v/error.rs b/src/api/k2v/error.rs
index 72e712bf..16479227 100644
--- a/src/api/k2v/error.rs
+++ b/src/api/k2v/error.rs
@@ -94,7 +94,7 @@ impl ApiError for Error {
header_map.append(header::CONTENT_TYPE, "application/json".parse().unwrap());
}
- fn http_body(&self, garage_region: &str, path: &str) -> BytesBody {
+ fn http_body(&self, garage_region: &str, path: &str) -> ErrorBody {
let error = CustomApiErrorBody {
code: self.code().to_string(),
message: format!("{}", self),
@@ -110,6 +110,6 @@ impl ApiError for Error {
"#
.into()
});
- string_bytes_body(error_str)
+ error_body(error_str)
}
}
diff --git a/src/api/s3/error.rs b/src/api/s3/error.rs
index a4d222de..f86c19a6 100644
--- a/src/api/s3/error.rs
+++ b/src/api/s3/error.rs
@@ -168,7 +168,7 @@ impl ApiError for Error {
}
}
- fn http_body(&self, garage_region: &str, path: &str) -> BytesBody {
+ fn http_body(&self, garage_region: &str, path: &str) -> ErrorBody {
let error = s3_xml::Error {
code: s3_xml::Value(self.aws_code().to_string()),
message: s3_xml::Value(format!("{}", self)),
@@ -185,6 +185,6 @@ impl ApiError for Error {
"#
.into()
});
- string_bytes_body(error_str)
+ error_body(error_str)
}
}