aboutsummaryrefslogtreecommitdiff
path: root/src/api/k2v/api_server.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-05-13 15:43:44 +0200
committerAlex Auvolat <alex@adnab.me>2022-05-13 15:43:44 +0200
commitec16d166f940f59098ae5cc0c0b3d8298f1bcc78 (patch)
tree3dc5a6c7e655df875aa12aa86b6316f7948d51c1 /src/api/k2v/api_server.rs
parent7a5d329e49cc7018cbfa14d37589f51860f66cf0 (diff)
downloadgarage-ec16d166f940f59098ae5cc0c0b3d8298f1bcc78.tar.gz
garage-ec16d166f940f59098ae5cc0c0b3d8298f1bcc78.zip
Separate error types for k2v and signature
Diffstat (limited to 'src/api/k2v/api_server.rs')
-rw-r--r--src/api/k2v/api_server.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/api/k2v/api_server.rs b/src/api/k2v/api_server.rs
index 38ef8d45..b70fcdff 100644
--- a/src/api/k2v/api_server.rs
+++ b/src/api/k2v/api_server.rs
@@ -12,7 +12,7 @@ use garage_util::error::Error as GarageError;
use garage_model::garage::Garage;
-use crate::s3::error::*;
+use crate::k2v::error::*;
use crate::generic_server::*;
use crate::signature::payload::check_payload_signature;
@@ -84,7 +84,8 @@ impl ApiHandler for K2VApiServer {
// The OPTIONS method is procesed early, before we even check for an API key
if let Endpoint::Options = endpoint {
- return handle_options_s3api(garage, &req, Some(bucket_name)).await;
+ return Ok(handle_options_s3api(garage, &req, Some(bucket_name)).await
+ .ok_or_bad_request("Error handling OPTIONS")?);
}
let (api_key, mut content_sha256) = check_payload_signature(&garage, "k2v", &req).await?;
@@ -126,7 +127,8 @@ impl ApiHandler for K2VApiServer {
// are always preflighted, i.e. the browser should make
// an OPTIONS call before to check it is allowed
let matching_cors_rule = match *req.method() {
- Method::GET | Method::HEAD | Method::POST => find_matching_cors_rule(&bucket, &req)?,
+ Method::GET | Method::HEAD | Method::POST => find_matching_cors_rule(&bucket, &req)
+ .ok_or_internal_error("Error looking up CORS rule")?,
_ => None,
};