aboutsummaryrefslogtreecommitdiff
path: root/src/api/s3_website.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-12-22 18:50:08 +0100
committerAlex Auvolat <alex@adnab.me>2022-01-04 12:47:28 +0100
commitd8ab5bdc3e20759e5ba8a6844393757da3539372 (patch)
tree7fc9abc578bb4185691313889ed94aedca09dbc4 /src/api/s3_website.rs
parentc7d5c732442c5802058b46205d450d4620772b7b (diff)
downloadgarage-d8ab5bdc3e20759e5ba8a6844393757da3539372.tar.gz
garage-d8ab5bdc3e20759e5ba8a6844393757da3539372.zip
New buckets for 0.6.0: fix model and migration
Diffstat (limited to 'src/api/s3_website.rs')
-rw-r--r--src/api/s3_website.rs24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/api/s3_website.rs b/src/api/s3_website.rs
index e76afbf4..1ea57577 100644
--- a/src/api/s3_website.rs
+++ b/src/api/s3_website.rs
@@ -3,12 +3,12 @@ use std::sync::Arc;
use hyper::{Body, Request, Response, StatusCode};
use serde::{Deserialize, Serialize};
-use serde_bytes::ByteBuf;
use crate::error::*;
use crate::s3_xml::{xmlns_tag, IntValue, Value};
use crate::signature::verify_signed_content;
+use garage_model::bucket_table::*;
use garage_model::garage::Garage;
use garage_table::*;
use garage_util::crdt;
@@ -58,7 +58,7 @@ pub async fn handle_put_website(
if let crdt::Deletable::Present(param) = &mut bucket.state {
param
.website_config
- .update(Some(ByteBuf::from(body.to_vec())));
+ .update(Some(conf.into_garage_website_config()?));
garage.bucket_table.insert(&bucket).await?;
} else {
unreachable!();
@@ -168,6 +168,26 @@ impl WebsiteConfiguration {
Ok(())
}
+
+ pub fn into_garage_website_config(self) -> Result<WebsiteConfig, Error> {
+ if let Some(rart) = self.redirect_all_requests_to {
+ Ok(WebsiteConfig::RedirectAll {
+ hostname: rart.hostname.0,
+ protocol: rart
+ .protocol
+ .map(|x| x.0)
+ .unwrap_or_else(|| "http".to_string()),
+ })
+ } else {
+ Ok(WebsiteConfig::Website {
+ index_document: self
+ .index_document
+ .map(|x| x.suffix.0)
+ .unwrap_or_else(|| "index.html".to_string()),
+ error_document: self.error_document.map(|x| x.key.0),
+ })
+ }
+ }
}
impl Key {