aboutsummaryrefslogtreecommitdiff
path: root/src/api/api_server.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-04-26 16:22:33 +0000
committerAlex Auvolat <alex@adnab.me>2020-04-26 16:22:33 +0000
commitea7e4748edb32bcbcf737dcf35322eb6496b3439 (patch)
treee64ab989a056c636ac3e173d26f5fd69ad8a06f8 /src/api/api_server.rs
parent0e49e0c8b59a77ba44733cfd3941433f11258d72 (diff)
downloadgarage-ea7e4748edb32bcbcf737dcf35322eb6496b3439.tar.gz
garage-ea7e4748edb32bcbcf737dcf35322eb6496b3439.zip
S3 compatibility: fix bucket listing and HEAD and PUT on bucket
Diffstat (limited to 'src/api/api_server.rs')
-rw-r--r--src/api/api_server.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/api/api_server.rs b/src/api/api_server.rs
index 58ef9460..4413c7d2 100644
--- a/src/api/api_server.rs
+++ b/src/api/api_server.rs
@@ -125,8 +125,18 @@ async fn handler_inner(
}
} else {
match req.method() {
- &Method::PUT | &Method::DELETE => Err(Error::Forbidden(
- "Cannot create or delete buckets using S3 api, please talk to Garage directly"
+ &Method::PUT | &Method::HEAD => {
+ // If PUT: corresponds to a bucket creation call
+ // If we're here, the bucket already exists, so just answer ok
+ let empty_body: BodyType = Box::new(BytesBody::from(vec![]));
+ let response = Response::builder()
+ .header("Location", format!("/{}", bucket))
+ .body(empty_body)
+ .unwrap();
+ Ok(response)
+ },
+ &Method::DELETE => Err(Error::Forbidden(
+ "Cannot delete buckets using S3 api, please talk to Garage directly"
.into(),
)),
&Method::GET => {