mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-21 11:56:38 +00:00
add admin api response content-type
This commit is contained in:
@@ -27,6 +27,7 @@ use iam::{auth, get_global_action_cred};
|
|||||||
use madmin::metrics::RealtimeMetrics;
|
use madmin::metrics::RealtimeMetrics;
|
||||||
use madmin::utils::parse_duration;
|
use madmin::utils::parse_duration;
|
||||||
use matchit::Params;
|
use matchit::Params;
|
||||||
|
use s3s::header::CONTENT_TYPE;
|
||||||
use s3s::stream::{ByteStream, DynByteStream};
|
use s3s::stream::{ByteStream, DynByteStream};
|
||||||
use s3s::{
|
use s3s::{
|
||||||
dto::{AssumeRoleOutput, Credentials, Timestamp},
|
dto::{AssumeRoleOutput, Credentials, Timestamp},
|
||||||
@@ -354,10 +355,13 @@ impl Operation for AccountInfoHandler {
|
|||||||
policy: bucket_policy,
|
policy: bucket_policy,
|
||||||
};
|
};
|
||||||
|
|
||||||
let output = serde_json::to_string(&info)
|
let data = serde_json::to_vec(&info)
|
||||||
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse accountInfo failed"))?;
|
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse accountInfo failed"))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::from(output))))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,10 +384,13 @@ impl Operation for ServerInfoHandler {
|
|||||||
|
|
||||||
let info = get_server_info(true).await;
|
let info = get_server_info(true).await;
|
||||||
|
|
||||||
let output = serde_json::to_string(&info)
|
let data = serde_json::to_vec(&info)
|
||||||
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse serverInfo failed"))?;
|
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse serverInfo failed"))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::from(output))))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,10 +420,13 @@ impl Operation for StorageInfoHandler {
|
|||||||
|
|
||||||
let info = store.storage_info().await;
|
let info = store.storage_info().await;
|
||||||
|
|
||||||
let output = serde_json::to_string(&info)
|
let data = serde_json::to_vec(&info)
|
||||||
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse accountInfo failed"))?;
|
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse accountInfo failed"))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::from(output))))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,10 +446,13 @@ impl Operation for DataUsageInfoHandler {
|
|||||||
s3_error!(InternalError, "load_data_usage_from_backend failed")
|
s3_error!(InternalError, "load_data_usage_from_backend failed")
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
let output = serde_json::to_string(&info)
|
let data = serde_json::to_vec(&info)
|
||||||
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse DataUsageInfo failed"))?;
|
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse DataUsageInfo failed"))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::from(output))))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -860,10 +873,13 @@ impl Operation for ListPools {
|
|||||||
pools_status.push(state);
|
pools_status.push(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
let output = serde_json::to_string(&pools_status)
|
let data = serde_json::to_vec(&pools_status)
|
||||||
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse accountInfo failed"))?;
|
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse accountInfo failed"))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::from(output))))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -927,10 +943,13 @@ impl Operation for StatusPool {
|
|||||||
|
|
||||||
let pools_status = store.status(idx).await.map_err(to_s3_error)?;
|
let pools_status = store.status(idx).await.map_err(to_s3_error)?;
|
||||||
|
|
||||||
let output = serde_json::to_string(&pools_status)
|
let data = serde_json::to_vec(&pools_status)
|
||||||
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse accountInfo failed"))?;
|
.map_err(|_e| S3Error::with_message(S3ErrorCode::InternalError, "parse accountInfo failed"))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::from(output))))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use iam::{error::is_err_no_such_user, get_global_action_cred, Error};
|
use iam::{error::is_err_no_such_user, get_global_action_cred};
|
||||||
use madmin::GroupAddRemove;
|
use madmin::GroupAddRemove;
|
||||||
use matchit::Params;
|
use matchit::Params;
|
||||||
use s3s::{s3_error, Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result};
|
use s3s::{s3_error, Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
|
use http::HeaderMap;
|
||||||
use hyper::StatusCode;
|
use hyper::StatusCode;
|
||||||
use iam::{
|
use iam::{
|
||||||
auth::CredentialsBuilder,
|
auth::CredentialsBuilder,
|
||||||
@@ -10,7 +11,7 @@ use iam::{
|
|||||||
};
|
};
|
||||||
use madmin::{AddServiceAccountReq, ListServiceAccountsResp, ServiceAccountInfo};
|
use madmin::{AddServiceAccountReq, ListServiceAccountsResp, ServiceAccountInfo};
|
||||||
use matchit::Params;
|
use matchit::Params;
|
||||||
use s3s::{s3_error, Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result};
|
use s3s::{header::CONTENT_TYPE, s3_error, Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result};
|
||||||
use serde_urlencoded::from_bytes;
|
use serde_urlencoded::from_bytes;
|
||||||
use tracing::{debug, warn};
|
use tracing::{debug, warn};
|
||||||
|
|
||||||
@@ -277,7 +278,10 @@ impl Operation for ListServiceAccount {
|
|||||||
let data = serde_json::to_vec(&ListServiceAccountsResp { accounts })
|
let data = serde_json::to_vec(&ListServiceAccountsResp { accounts })
|
||||||
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("marshal users err {}", e)))?;
|
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("marshal users err {}", e)))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::from(data))))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
use http::StatusCode;
|
use http::{HeaderMap, StatusCode};
|
||||||
use iam::get_global_action_cred;
|
use iam::get_global_action_cred;
|
||||||
use madmin::{AccountStatus, AddOrUpdateUserReq};
|
use madmin::{AccountStatus, AddOrUpdateUserReq};
|
||||||
use matchit::Params;
|
use matchit::Params;
|
||||||
use s3s::{s3_error, Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result};
|
use s3s::{header::CONTENT_TYPE, s3_error, Body, S3Error, S3ErrorCode, S3Request, S3Response, S3Result};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_urlencoded::from_bytes;
|
use serde_urlencoded::from_bytes;
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
@@ -87,7 +87,10 @@ impl Operation for AddUser {
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("create_user err {}", e)))?;
|
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("create_user err {}", e)))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::empty())))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +131,10 @@ impl Operation for SetUserStatus {
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("set_user_status err {}", e)))?;
|
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("set_user_status err {}", e)))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::empty())))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,7 +157,10 @@ impl Operation for ListUsers {
|
|||||||
// let body = encrypt_data(input_cred.secret_key.expose().as_bytes(), &data)
|
// let body = encrypt_data(input_cred.secret_key.expose().as_bytes(), &data)
|
||||||
// .map_err(|e| S3Error::with_message(S3ErrorCode::InvalidArgument, format!("encrypt_data err {}", e)))?;
|
// .map_err(|e| S3Error::with_message(S3ErrorCode::InvalidArgument, format!("encrypt_data err {}", e)))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::from(data))))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,7 +197,10 @@ impl Operation for RemoveUser {
|
|||||||
.await
|
.await
|
||||||
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("delete_user err {}", e)))?;
|
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("delete_user err {}", e)))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::empty())))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::empty()), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,6 +232,9 @@ impl Operation for GetUserInfo {
|
|||||||
let data = serde_json::to_vec(&info)
|
let data = serde_json::to_vec(&info)
|
||||||
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("marshal user err {}", e)))?;
|
.map_err(|e| S3Error::with_message(S3ErrorCode::InternalError, format!("marshal user err {}", e)))?;
|
||||||
|
|
||||||
Ok(S3Response::new((StatusCode::OK, Body::from(data))))
|
let mut header = HeaderMap::new();
|
||||||
|
header.insert(CONTENT_TYPE, "application/json".parse().unwrap());
|
||||||
|
|
||||||
|
Ok(S3Response::with_headers((StatusCode::OK, Body::from(data)), header))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user