aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorJonathan Davies <jpds@protonmail.com>2023-01-29 01:16:04 +0000
committerJonathan Davies <jpds@protonmail.com>2023-01-29 20:34:37 +0000
commit004bb5b4f1b2086914376265425fd46df5059db3 (patch)
tree8058229dec5ef06d9deac1d87a4aefc9d9e4c991 /src/api
parentdf30f3df4b2b6cb67c4e37117fb30d6f61cfefc5 (diff)
downloadgarage-004bb5b4f1b2086914376265425fd46df5059db3.tar.gz
garage-004bb5b4f1b2086914376265425fd46df5059db3.zip
api_server.rs: Adapted to use query string per Caddy upstream change.
Diffstat (limited to 'src/api')
-rw-r--r--src/api/admin/api_server.rs34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/api/admin/api_server.rs b/src/api/admin/api_server.rs
index a115d732..dae42059 100644
--- a/src/api/admin/api_server.rs
+++ b/src/api/admin/api_server.rs
@@ -1,3 +1,4 @@
+use std::collections::HashMap;
use std::net::SocketAddr;
use std::sync::Arc;
@@ -81,29 +82,32 @@ impl AdminApiServer {
&self,
req: Request<Body>,
) -> Result<Response<Body>, Error> {
- let has_domain_header = req.headers().contains_key("domain");
-
- if !has_domain_header {
- return Err(Error::bad_request("No domain header found"));
+ let query_params: HashMap<String, String> = req
+ .uri()
+ .query()
+ .map(|v| {
+ url::form_urlencoded::parse(v.as_bytes())
+ .into_owned()
+ .collect()
+ })
+ .unwrap_or_else(HashMap::new);
+
+ let has_domain_key = query_params.contains_key("domain");
+
+ if !has_domain_key {
+ return Err(Error::bad_request("No domain query string found"));
}
- let domain = &req
- .headers()
+ let domain = query_params
.get("domain")
- .ok_or_internal_error("Could not parse domain header")?;
-
- let domain_string = String::from(
- domain
- .to_str()
- .ok_or_bad_request("Invalid characters found in domain header")?,
- );
+ .ok_or_internal_error("Could not parse domain query string")?;
let bucket_id = self
.garage
.bucket_helper()
- .resolve_global_bucket_name(&domain_string)
+ .resolve_global_bucket_name(&domain)
.await?
- .ok_or(HelperError::NoSuchBucket(domain_string))?;
+ .ok_or(HelperError::NoSuchBucket(domain.to_string()))?;
let bucket = self
.garage