mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-09-02 10:18:11 +00:00
admin api: allow updating website routing rules
This commit is contained in:
@@ -149,30 +149,7 @@ impl WebsiteConfiguration {
|
||||
.routing_rules
|
||||
.rules
|
||||
.into_iter()
|
||||
.map(|rule| {
|
||||
bucket_table::RoutingRule {
|
||||
condition: rule.condition.map(|condition| {
|
||||
bucket_table::RedirectCondition {
|
||||
http_error_code: condition.http_error_code.map(|c| c.0 as u16),
|
||||
prefix: condition.prefix.map(|p| p.0),
|
||||
}
|
||||
}),
|
||||
redirect: bucket_table::Redirect {
|
||||
hostname: rule.redirect.hostname.map(|h| h.0),
|
||||
protocol: rule.redirect.protocol.map(|p| p.0),
|
||||
// aws default to 301, which i find punitive in case of
|
||||
// misconfiguration (can be permanently cached on the
|
||||
// user agent)
|
||||
http_redirect_code: rule
|
||||
.redirect
|
||||
.http_redirect_code
|
||||
.map(|c| c.0 as u16)
|
||||
.unwrap_or(302),
|
||||
replace_key_prefix: rule.redirect.replace_prefix.map(|k| k.0),
|
||||
replace_key: rule.redirect.replace_full.map(|k| k.0),
|
||||
},
|
||||
}
|
||||
})
|
||||
.map(RoutingRule::into_garage_routing_rule)
|
||||
.collect(),
|
||||
})
|
||||
}
|
||||
@@ -237,6 +214,31 @@ impl RoutingRule {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_garage_routing_rule(self) -> bucket_table::RoutingRule {
|
||||
bucket_table::RoutingRule {
|
||||
condition: self
|
||||
.condition
|
||||
.map(|condition| bucket_table::RedirectCondition {
|
||||
http_error_code: condition.http_error_code.map(|c| c.0 as u16),
|
||||
prefix: condition.prefix.map(|p| p.0),
|
||||
}),
|
||||
redirect: bucket_table::Redirect {
|
||||
hostname: self.redirect.hostname.map(|h| h.0),
|
||||
protocol: self.redirect.protocol.map(|p| p.0),
|
||||
// aws default to 301, which i find punitive in case of
|
||||
// misconfiguration (can be permanently cached on the
|
||||
// user agent)
|
||||
http_redirect_code: self
|
||||
.redirect
|
||||
.http_redirect_code
|
||||
.map(|c| c.0 as u16)
|
||||
.unwrap_or(302),
|
||||
replace_key_prefix: self.redirect.replace_prefix.map(|k| k.0),
|
||||
replace_key: self.redirect.replace_full.map(|k| k.0),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Condition {
|
||||
|
||||
Reference in New Issue
Block a user