aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3_router.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-01-07 16:23:04 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-24 11:58:00 +0100
commitea7fb901ebc316bba53d248a2f8bd7a3455f5791 (patch)
tree31da306e4c0b866bb9cc4241d6b01eac6c74bd49 /src/api/s3_router.rs
parent820924534ab3eb0b2544a594881591559e7c45a5 (diff)
downloadgarage-ea7fb901ebc316bba53d248a2f8bd7a3455f5791.tar.gz
garage-ea7fb901ebc316bba53d248a2f8bd7a3455f5791.zip
Implement {Put,Get,Delete}BucketCors and CORS in general
- OPTIONS request against API endpoint - Returning corresponding CORS headers on API calls - Returning corresponding CORS headers on website GET's
Diffstat (limited to 'src/api/s3_router.rs')
-rw-r--r--src/api/s3_router.rs15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/api/s3_router.rs b/src/api/s3_router.rs
index 9add5e4a..51020a81 100644
--- a/src/api/s3_router.rs
+++ b/src/api/s3_router.rs
@@ -327,6 +327,7 @@ pub enum Endpoint {
part_number_marker: Option<u64>,
upload_id: String,
},
+ Options,
PutBucketAccelerateConfiguration {
},
PutBucketAcl {
@@ -434,6 +435,10 @@ impl Endpoint {
.unwrap_or((path.to_owned(), ""))
};
+ if *req.method() == Method::OPTIONS {
+ return Ok((Self::Options, Some(bucket)));
+ }
+
let key = percent_encoding::percent_decode_str(key)
.decode_utf8()?
.into_owned();
@@ -665,7 +670,6 @@ impl Endpoint {
GetBucketAccelerateConfiguration,
GetBucketAcl,
GetBucketAnalyticsConfiguration,
- GetBucketCors,
GetBucketEncryption,
GetBucketIntelligentTieringConfiguration,
GetBucketInventoryConfiguration,
@@ -711,6 +715,9 @@ impl Endpoint {
GetBucketWebsite,
PutBucketWebsite,
DeleteBucketWebsite,
+ GetBucketCors,
+ PutBucketCors,
+ DeleteBucketCors,
]
};
if readonly {
@@ -1027,7 +1034,7 @@ mod tests {
OWNER_DELETE "/" => DeleteBucket
DELETE "/?analytics&id=list1" => DeleteBucketAnalyticsConfiguration
DELETE "/?analytics&id=Id" => DeleteBucketAnalyticsConfiguration
- DELETE "/?cors" => DeleteBucketCors
+ OWNER_DELETE "/?cors" => DeleteBucketCors
DELETE "/?encryption" => DeleteBucketEncryption
DELETE "/?intelligent-tiering&id=Id" => DeleteBucketIntelligentTieringConfiguration
DELETE "/?inventory&id=list1" => DeleteBucketInventoryConfiguration
@@ -1050,7 +1057,7 @@ mod tests {
GET "/?accelerate" => GetBucketAccelerateConfiguration
GET "/?acl" => GetBucketAcl
GET "/?analytics&id=Id" => GetBucketAnalyticsConfiguration
- GET "/?cors" => GetBucketCors
+ OWNER_GET "/?cors" => GetBucketCors
GET "/?encryption" => GetBucketEncryption
GET "/?intelligent-tiering&id=Id" => GetBucketIntelligentTieringConfiguration
GET "/?inventory&id=list1" => GetBucketInventoryConfiguration
@@ -1126,7 +1133,7 @@ mod tests {
PUT "/?acl" => PutBucketAcl
PUT "/?analytics&id=report1" => PutBucketAnalyticsConfiguration
PUT "/?analytics&id=Id" => PutBucketAnalyticsConfiguration
- PUT "/?cors" => PutBucketCors
+ OWNER_PUT "/?cors" => PutBucketCors
PUT "/?encryption" => PutBucketEncryption
PUT "/?intelligent-tiering&id=Id" => PutBucketIntelligentTieringConfiguration
PUT "/?inventory&id=report1" => PutBucketInventoryConfiguration