From 921cfb849c5a72c36c29611a55fca11181963b54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Fri, 13 Feb 2026 10:36:54 +0800 Subject: [PATCH] refactor(admin): move accountinfo route registration (#1790) --- rustfs/src/admin/handlers/account_info.rs | 16 +++++++++++++--- rustfs/src/admin/handlers/user.rs | 9 ++------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/rustfs/src/admin/handlers/account_info.rs b/rustfs/src/admin/handlers/account_info.rs index 0fe52d74e..76eaa114c 100644 --- a/rustfs/src/admin/handlers/account_info.rs +++ b/rustfs/src/admin/handlers/account_info.rs @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -use crate::admin::router::Operation; +use crate::admin::router::{AdminOperation, Operation, S3Router}; use crate::auth::{check_key_valid, get_condition_values, get_session_token}; -use crate::server::RemoteAddr; +use crate::server::{ADMIN_PREFIX, RemoteAddr}; use http::{HeaderMap, HeaderValue}; -use hyper::StatusCode; +use hyper::{Method, StatusCode}; use matchit::Params; use rustfs_credentials::get_global_action_cred; use rustfs_ecstore::bucket::versioning_sys::BucketVersioningSys; @@ -43,6 +43,16 @@ pub struct AccountInfo { pub struct AccountInfoHandler {} +pub fn register_account_info_route(r: &mut S3Router) -> std::io::Result<()> { + r.insert( + Method::GET, + format!("{}{}", ADMIN_PREFIX, "/v3/accountinfo").as_str(), + AdminOperation(&AccountInfoHandler {}), + )?; + + Ok(()) +} + fn resolve_bucket_access(can_list_bucket: bool, can_get_bucket_location: bool, can_put_object: bool) -> (bool, bool) { (can_list_bucket || can_get_bucket_location, can_put_object) } diff --git a/rustfs/src/admin/handlers/user.rs b/rustfs/src/admin/handlers/user.rs index bde3af6e7..6c99dc11d 100644 --- a/rustfs/src/admin/handlers/user.rs +++ b/rustfs/src/admin/handlers/user.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use super::{account_info::AccountInfoHandler, event, group, policies, service_account}; +use super::{account_info, event, group, policies, service_account}; use crate::{ admin::{ auth::validate_admin_request, @@ -57,6 +57,7 @@ pub struct AddUserQuery { } pub fn register_user_route(r: &mut S3Router) -> std::io::Result<()> { + account_info::register_account_info_route(r)?; register_user_management_route(r)?; group::register_group_management_route(r)?; service_account::register_service_account_route(r)?; @@ -68,12 +69,6 @@ pub fn register_user_route(r: &mut S3Router) -> std::io::Result< } fn register_user_management_route(r: &mut S3Router) -> std::io::Result<()> { - r.insert( - Method::GET, - format!("{}{}", ADMIN_PREFIX, "/v3/accountinfo").as_str(), - AdminOperation(&AccountInfoHandler {}), - )?; - r.insert( Method::GET, format!("{}{}", ADMIN_PREFIX, "/v3/list-users").as_str(),