diff options
author | Trinity Pointard <trinity.pointard@gmail.com> | 2022-01-20 21:27:17 +0100 |
---|---|---|
committer | Gitea <gitea@fake.local> | 2022-01-24 11:56:59 +0100 |
commit | 820924534ab3eb0b2544a594881591559e7c45a5 (patch) | |
tree | f81f08770d5a0b615cf9d6807de9f2cddad5afa0 /src/api | |
parent | 94f0e7c135798af4dcb023f846b6b0b4adb3b2da (diff) | |
download | garage-820924534ab3eb0b2544a594881591559e7c45a5.tar.gz garage-820924534ab3eb0b2544a594881591559e7c45a5.zip |
use clamp instead of min(max())
Diffstat (limited to 'src/api')
-rw-r--r-- | src/api/api_server.rs | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/src/api/api_server.rs b/src/api/api_server.rs index dfb8dfdb..11daae13 100644 --- a/src/api/api_server.rs +++ b/src/api/api_server.rs @@ -1,4 +1,3 @@ -use std::cmp::{max, min}; use std::net::SocketAddr; use std::sync::Arc; @@ -221,7 +220,7 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon bucket_name, bucket_id, delimiter: delimiter.map(|d| d.to_string()), - page_size: max_keys.map(|p| min(1000, max(1, p))).unwrap_or(1000), + page_size: max_keys.map(|p| p.clamp(1, 1000)).unwrap_or(1000), prefix: prefix.unwrap_or_default(), urlencode_resp: encoding_type.map(|e| e == "url").unwrap_or(false), }, @@ -251,7 +250,7 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon bucket_name, bucket_id, delimiter: delimiter.map(|d| d.to_string()), - page_size: max_keys.map(|p| min(1000, max(1, p))).unwrap_or(1000), + page_size: max_keys.map(|p| p.clamp(1, 1000)).unwrap_or(1000), urlencode_resp: encoding_type.map(|e| e == "url").unwrap_or(false), prefix: prefix.unwrap_or_default(), }, @@ -284,7 +283,7 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon bucket_name, bucket_id, delimiter: delimiter.map(|d| d.to_string()), - page_size: max_uploads.map(|p| min(1000, max(1, p))).unwrap_or(1000), + page_size: max_uploads.map(|p| p.clamp(1, 1000)).unwrap_or(1000), prefix: prefix.unwrap_or_default(), urlencode_resp: encoding_type.map(|e| e == "url").unwrap_or(false), }, |