aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3_bucket.rs
blob: cbefd005ab28529d46e803563688c26fec499d67 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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()))?)
}