aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3_bucket.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-04-28 01:05:40 +0200
committerAlex Auvolat <alex@adnab.me>2021-04-28 01:05:40 +0200
commitdcfc32cf85bc6276fdff2492898c1cbb527e9b9d (patch)
tree01ec3f7476733dab8c74ecb1c72b5061f6e5c8e1 /src/api/s3_bucket.rs
parent368eb354846790e9fc616d9a26ddc414748d847f (diff)
downloadgarage-dcfc32cf85bc6276fdff2492898c1cbb527e9b9d.tar.gz
garage-dcfc32cf85bc6276fdff2492898c1cbb527e9b9d.zip
Many S3 compatibility improvements:v0.2.1.5
- return XML errors - implement AuthorizationHeaderMalformed error to redirect clients to correct location (used by minio client) - implement GetBucketLocation - fix DeleteObjects XML parsing and response
Diffstat (limited to 'src/api/s3_bucket.rs')
-rw-r--r--src/api/s3_bucket.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/api/s3_bucket.rs b/src/api/s3_bucket.rs
new file mode 100644
index 00000000..cbefd005
--- /dev/null
+++ b/src/api/s3_bucket.rs
@@ -0,0 +1,24 @@
+use std::fmt::Write;
+use std::sync::Arc;
+
+use hyper::{Body, Response};
+
+use garage_model::garage::Garage;
+
+use crate::error::*;
+
+pub fn handle_get_bucket_location(garage: Arc<Garage>) -> Result<Response<Body>, Error> {
+ let mut xml = String::new();
+
+ writeln!(&mut xml, r#"<?xml version="1.0" encoding="UTF-8"?>"#).unwrap();
+ writeln!(
+ &mut xml,
+ r#"<LocationConstraint xmlns="http://s3.amazonaws.com/doc/2006-03-01/">{}</LocationConstraint>"#,
+ garage.config.s3_api.s3_region
+ )
+ .unwrap();
+
+ Ok(Response::builder()
+ .header("Content-Type", "application/xml")
+ .body(Body::from(xml.into_bytes()))?)
+}