aboutsummaryrefslogtreecommitdiff
path: root/src/api/api_server.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-26 10:20:05 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-26 10:20:05 +0200
commitada7899b24cacb4f95ee67ae92ddb73c04ee4d66 (patch)
treee42c200cd5eb9e9190232d4340f5be27f302342c /src/api/api_server.rs
parentb2c51844a1dccf229473ce0c27fdb02a433ac243 (diff)
downloadgarage-ada7899b24cacb4f95ee67ae92ddb73c04ee4d66.tar.gz
garage-ada7899b24cacb4f95ee67ae92ddb73c04ee4d66.zip
Fix clippy lints (fix #121)
Diffstat (limited to 'src/api/api_server.rs')
-rw-r--r--src/api/api_server.rs35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/api/api_server.rs b/src/api/api_server.rs
index 52031ae0..d51b5a28 100644
--- a/src/api/api_server.rs
+++ b/src/api/api_server.rs
@@ -39,7 +39,7 @@ pub async fn run_api_server(
}
});
- let server = Server::bind(&addr).serve(service);
+ let server = Server::bind(addr).serve(service);
let graceful = server.with_graceful_shutdown(shutdown_signal);
info!("API server listening on http://{}", addr);
@@ -88,8 +88,8 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
let (bucket, key) = parse_bucket_key(&path)?;
let allowed = match req.method() {
- &Method::HEAD | &Method::GET => api_key.allow_read(&bucket),
- _ => api_key.allow_write(&bucket),
+ &Method::HEAD | &Method::GET => api_key.allow_read(bucket),
+ _ => api_key.allow_write(bucket),
};
if !allowed {
return Err(Error::Forbidden(
@@ -109,11 +109,11 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
match *req.method() {
Method::HEAD => {
// HeadObject query
- Ok(handle_head(garage, &req, &bucket, &key).await?)
+ Ok(handle_head(garage, &req, bucket, key).await?)
}
Method::GET => {
// GetObject query
- Ok(handle_get(garage, &req, &bucket, &key).await?)
+ Ok(handle_get(garage, &req, bucket, key).await?)
}
Method::PUT => {
if params.contains_key(&"partnumber".to_string())
@@ -125,8 +125,8 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
Ok(handle_put_part(
garage,
req,
- &bucket,
- &key,
+ bucket,
+ key,
part_number,
upload_id,
content_sha256,
@@ -136,46 +136,43 @@ async fn handler_inner(garage: Arc<Garage>, req: Request<Body>) -> Result<Respon
// CopyObject query
let copy_source = req.headers().get("x-amz-copy-source").unwrap().to_str()?;
let copy_source =
- percent_encoding::percent_decode_str(&copy_source).decode_utf8()?;
+ percent_encoding::percent_decode_str(copy_source).decode_utf8()?;
let (source_bucket, source_key) = parse_bucket_key(&copy_source)?;
- if !api_key.allow_read(&source_bucket) {
+ if !api_key.allow_read(source_bucket) {
return Err(Error::Forbidden(format!(
"Reading from bucket {} not allowed for this key",
source_bucket
)));
}
let source_key = source_key.ok_or_bad_request("No source key specified")?;
- Ok(
- handle_copy(garage, &req, &bucket, &key, &source_bucket, &source_key)
- .await?,
- )
+ Ok(handle_copy(garage, &req, bucket, key, source_bucket, source_key).await?)
} else {
// PutObject query
- Ok(handle_put(garage, req, &bucket, &key, content_sha256).await?)
+ Ok(handle_put(garage, req, bucket, key, content_sha256).await?)
}
}
Method::DELETE => {
if params.contains_key(&"uploadid".to_string()) {
// AbortMultipartUpload query
let upload_id = params.get("uploadid").unwrap();
- Ok(handle_abort_multipart_upload(garage, &bucket, &key, upload_id).await?)
+ Ok(handle_abort_multipart_upload(garage, bucket, key, upload_id).await?)
} else {
// DeleteObject query
- Ok(handle_delete(garage, &bucket, &key).await?)
+ Ok(handle_delete(garage, bucket, key).await?)
}
}
Method::POST => {
if params.contains_key(&"uploads".to_string()) {
// CreateMultipartUpload call
- Ok(handle_create_multipart_upload(garage, &req, &bucket, &key).await?)
+ Ok(handle_create_multipart_upload(garage, &req, bucket, key).await?)
} else if params.contains_key(&"uploadid".to_string()) {
// CompleteMultipartUpload call
let upload_id = params.get("uploadid").unwrap();
Ok(handle_complete_multipart_upload(
garage,
req,
- &bucket,
- &key,
+ bucket,
+ key,
upload_id,
content_sha256,
)