aboutsummaryrefslogtreecommitdiff
path: root/src/api/api_server.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-02-28 11:15:53 +0100
committerAlex Auvolat <alex@adnab.me>2022-02-28 12:22:39 +0100
commit8129a9829165c8543b2ab2d32e8f20ed54ced9e5 (patch)
tree5a1eae4279761a82722dc1224b1261a72aba96da /src/api/api_server.rs
parent54e02b4c3ba466988c50984aba9b60dc51b6cdce (diff)
downloadgarage-8129a9829165c8543b2ab2d32e8f20ed54ced9e5.tar.gz
garage-8129a9829165c8543b2ab2d32e8f20ed54ced9e5.zip
Process CORS earlier in pipeline
Diffstat (limited to 'src/api/api_server.rs')
-rw-r--r--src/api/api_server.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/api/api_server.rs b/src/api/api_server.rs
index 77587de8..5ac78bf4 100644
--- a/src/api/api_server.rs
+++ b/src/api/api_server.rs
@@ -111,9 +111,13 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
let (endpoint, bucket_name) = Endpoint::from_request(&req, bucket_name.map(ToOwned::to_owned))?;
debug!("Endpoint: {:?}", endpoint);
- if let Endpoint::PostObject {} = endpoint {
+ // Some endpoints are processed early, before we even check for an API key
+ if let Endpoint::PostObject = endpoint {
return handle_post_object(garage, req, bucket_name.unwrap()).await;
}
+ if let Endpoint::Options = endpoint {
+ return handle_options(garage, &req, bucket_name).await;
+ }
let (api_key, content_sha256) = check_payload_signature(&garage, &req).await?;
let api_key = api_key.ok_or_else(|| {
@@ -161,7 +165,6 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
};
let resp = match endpoint {
- Endpoint::Options => handle_options(&req, &bucket).await,
Endpoint::HeadObject {
key, part_number, ..
} => handle_head(garage, &req, bucket_id, &key, part_number).await,