diff options
author | Alex Auvolat <alex@adnab.me> | 2022-05-25 17:05:56 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-05-25 17:09:33 +0200 |
commit | ff06d3f0829464863e64ed55471f2caa13bed191 (patch) | |
tree | 2ba08f439721c28d326badc0a33f148ee1fbdce1 /src/api/admin/bucket.rs | |
parent | 93eab8eaa3927b99626fee4a747a0f9f041cafdb (diff) | |
download | garage-ff06d3f0829464863e64ed55471f2caa13bed191.tar.gz garage-ff06d3f0829464863e64ed55471f2caa13bed191.zip |
Fix Content-Type headers for {admin,k2v} errors and admin responsesfix/admin-api-content-type
Fix #315
Diffstat (limited to 'src/api/admin/bucket.rs')
-rw-r--r-- | src/api/admin/bucket.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/api/admin/bucket.rs b/src/api/admin/bucket.rs index 849d28ac..7f9a813f 100644 --- a/src/api/admin/bucket.rs +++ b/src/api/admin/bucket.rs @@ -6,7 +6,6 @@ use serde::{Deserialize, Serialize}; use garage_util::crdt::*; use garage_util::data::*; -use garage_util::error::Error as GarageError; use garage_util::time::*; use garage_table::*; @@ -19,7 +18,7 @@ use garage_model::permission::*; use crate::admin::error::*; use crate::admin::key::ApiBucketKeyPerm; use crate::common_error::CommonError; -use crate::helpers::parse_json_body; +use crate::helpers::{json_ok_response, parse_json_body}; pub async fn handle_list_buckets(garage: &Arc<Garage>) -> Result<Response<Body>, Error> { let buckets = garage @@ -60,10 +59,7 @@ pub async fn handle_list_buckets(garage: &Arc<Garage>) -> Result<Response<Body>, }) .collect::<Vec<_>>(); - let resp_json = serde_json::to_string_pretty(&res).map_err(GarageError::from)?; - Ok(Response::builder() - .status(StatusCode::OK) - .body(Body::from(resp_json))?) + Ok(json_ok_response(&res)?) } #[derive(Serialize)] @@ -197,10 +193,7 @@ async fn bucket_info_results( .collect::<Vec<_>>(), }; - let resp_json = serde_json::to_string_pretty(&res).map_err(GarageError::from)?; - Ok(Response::builder() - .status(StatusCode::OK) - .body(Body::from(resp_json))?) + Ok(json_ok_response(&res)?) } #[derive(Serialize)] |