diff options
author | Alex Auvolat <alex@adnab.me> | 2022-05-13 15:04:53 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-05-13 15:04:53 +0200 |
commit | 96b11524d53b3616a28f33e2b057655be1639f6f (patch) | |
tree | 324a8a9624c5b861fb5a09b0ae0e0c07f6b9614c /src/web/web_server.rs | |
parent | c0fb9fd0fe553e5eda39dcb1a09f059bcd631b6c (diff) | |
download | garage-96b11524d53b3616a28f33e2b057655be1639f6f.tar.gz garage-96b11524d53b3616a28f33e2b057655be1639f6f.zip |
Error refactoring
Diffstat (limited to 'src/web/web_server.rs')
-rw-r--r-- | src/web/web_server.rs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/web/web_server.rs b/src/web/web_server.rs index 867adc51..e83bc4cb 100644 --- a/src/web/web_server.rs +++ b/src/web/web_server.rs @@ -207,7 +207,7 @@ async fn serve_file(garage: Arc<Garage>, req: &Request<Body>) -> Result<Response Method::OPTIONS => handle_options_for_bucket(req, &bucket), Method::HEAD => handle_head(garage.clone(), req, bucket_id, &key, None).await, Method::GET => handle_get(garage.clone(), req, bucket_id, &key, None).await, - _ => Err(ApiError::BadRequest("HTTP method not supported".into())), + _ => Err(ApiError::bad_request("HTTP method not supported")), } .map_err(Error::from); @@ -290,9 +290,7 @@ fn path_to_key<'a>(path: &'a str, index: &str) -> Result<Cow<'a, str>, Error> { let path_utf8 = percent_encoding::percent_decode_str(path).decode_utf8()?; if !path_utf8.starts_with('/') { - return Err(Error::BadRequest( - "Path must start with a / (slash)".to_string(), - )); + return Err(Error::BadRequest("Path must start with a / (slash)".into())); } match path_utf8.chars().last() { |