From 7d8f7a12ba4e92b6e53f238ae11fa3551c2d2959 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Thu, 12 Feb 2026 21:28:48 +0800 Subject: [PATCH] refactor(admin): modularize handlers and route registration (#1787) --- AGENTS.md | 2 +- .../admin/{handlers.rs => handlers/mod.rs} | 0 rustfs/src/admin/mod.rs | 24 ++++++++++++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) rename rustfs/src/admin/{handlers.rs => handlers/mod.rs} (100%) diff --git a/AGENTS.md b/AGENTS.md index fcc2904c5..3cdfcd83b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,7 +18,7 @@ Or simply run `make pre-commit` which covers all checks. **DO NOT commit if any ## Communication Rules -- Respond to the user in English. +- Respond to the user in the same language used by the user. - Code and documentation must be written in English only. - **Pull Request titles and descriptions must be written in English** to ensure consistency and accessibility for all contributors. diff --git a/rustfs/src/admin/handlers.rs b/rustfs/src/admin/handlers/mod.rs similarity index 100% rename from rustfs/src/admin/handlers.rs rename to rustfs/src/admin/handlers/mod.rs diff --git a/rustfs/src/admin/mod.rs b/rustfs/src/admin/mod.rs index 4f23261f2..2cbaf9ebc 100644 --- a/rustfs/src/admin/mod.rs +++ b/rustfs/src/admin/mod.rs @@ -240,6 +240,14 @@ pub fn make_admin_route(console_enabled: bool) -> std::io::Result AdminOperation(&bucket_meta::ImportBucketMetadata {}), )?; + register_replication_route(&mut r)?; + register_profiling_route(&mut r)?; + register_kms_route(&mut r)?; + + Ok(r) +} + +fn register_replication_route(r: &mut S3Router) -> std::io::Result<()> { r.insert( Method::GET, format!("{}{}", ADMIN_PREFIX, "/v3/list-remote-targets").as_str(), @@ -264,6 +272,10 @@ pub fn make_admin_route(console_enabled: bool) -> std::io::Result AdminOperation(&RemoveRemoteTargetHandler {}), )?; + Ok(()) +} + +fn register_profiling_route(r: &mut S3Router) -> std::io::Result<()> { // Performance profiling endpoints (available on all platforms, with platform-specific responses) r.insert( Method::GET, @@ -277,6 +289,10 @@ pub fn make_admin_route(console_enabled: bool) -> std::io::Result AdminOperation(&handlers::ProfileStatusHandler {}), )?; + Ok(()) +} + +fn register_kms_route(r: &mut S3Router) -> std::io::Result<()> { // KMS management endpoints r.insert( Method::POST, @@ -382,7 +398,7 @@ pub fn make_admin_route(console_enabled: bool) -> std::io::Result AdminOperation(&kms_keys::DescribeKmsKeyHandler {}), )?; - Ok(r) + Ok(()) } /// user router @@ -537,6 +553,12 @@ fn register_user_route(r: &mut S3Router) -> std::io::Result<()> AdminOperation(&policies::SetPolicyForUserOrGroup {}), )?; + register_notification_target_route(r)?; + + Ok(()) +} + +fn register_notification_target_route(r: &mut S3Router) -> std::io::Result<()> { r.insert( Method::GET, format!("{}{}", ADMIN_PREFIX, "/v3/target/list").as_str(),