support redirection on s3 endpoint #910

Merged
lx merged 13 commits from trinity-1686a/garage:1686a/s3-redirects into next-v2 2025-02-14 12:58:48 +00:00
4 changed files with 13 additions and 0 deletions
Showing only changes of commit bf0f792418 - Show all commits

View file

@ -423,6 +423,7 @@ pub async fn handle_update_bucket(
"Please specify indexDocument when enabling website access.",
)?,
error_document: wa.error_document,
redirect_all: None,
routing_rules: Vec::new(),
}));
} else {

View file

@ -238,6 +238,7 @@ impl WebsiteConfiguration {
.map(|x| x.suffix.0)
.unwrap_or_else(|| "index.html".to_string()),
error_document: self.error_document.map(|x| x.key.0),
redirect_all: None,
routing_rules: self
.routing_rules
.rules

View file

@ -393,6 +393,7 @@ impl AdminRpcHandler {
Some(WebsiteConfig {
index_document: query.index_document.clone(),
error_document: query.error_document.clone(),
redirect_all: None,
routing_rules: Vec::new(),
})
} else {

View file

@ -171,9 +171,18 @@ mod v2 {
pub struct WebsiteConfig {
pub index_document: String,
pub error_document: Option<String>,
// this field is currently unused, but present so adding it in the future doesn't
// need a new migration
pub redirect_all: Option<RedirectAll>,
pub routing_rules: Vec<RoutingRule>,
}
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
pub struct RedirectAll {
pub hostname: String,
pub protocol: String,
}
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
pub struct RoutingRule {
pub condition: Option<Condition>,
@ -212,6 +221,7 @@ mod v2 {
wc_opt.map(|wc| WebsiteConfig {
index_document: wc.index_document,
error_document: wc.error_document,
redirect_all: None,
routing_rules: vec![],
})
}),