mirror of
https://github.com/fawney19/Aether.git
synced 2026-10-13 04:29:50 +08:00
refactor: 拆分 admin handler 大文件为模块目录,消除 shared.rs 反模式
- endpoint_keys/pool/architecture 等大文件拆分为独立模块目录 - 删除 crud/query/strategy/system 中的 shared.rs,内容归位到各自模块 - endpoints_admin/models/oauth/write 等模块拆出 payloads/responses/support 子文件 - system/core 下多个 *_routes.rs 合并到 system_routes.rs - 更新 refactor-execution-plan 文档进度
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use super::super::write::{normalize_provider_billing_type, parse_optional_rfc3339_unix_secs};
|
||||
use super::shared::admin_provider_strategy_provider_not_found_response;
|
||||
use crate::handlers::admin::provider::shared::support::{
|
||||
normalize_provider_billing_type, parse_optional_rfc3339_unix_secs,
|
||||
};
|
||||
use crate::handlers::admin::shared::unix_secs_to_rfc3339;
|
||||
use crate::{AppState, GatewayError};
|
||||
use axum::{
|
||||
@@ -257,3 +258,11 @@ pub(super) async fn build_provider_strategy_reset_quota_response(
|
||||
}))
|
||||
.into_response())
|
||||
}
|
||||
|
||||
fn admin_provider_strategy_provider_not_found_response() -> Response<Body> {
|
||||
(
|
||||
http::StatusCode::NOT_FOUND,
|
||||
Json(json!({ "detail": "Provider not found" })),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ use axum::body::{Body, Bytes};
|
||||
use axum::http::Response;
|
||||
|
||||
mod builders;
|
||||
mod responses;
|
||||
mod routes;
|
||||
mod shared;
|
||||
|
||||
pub(crate) async fn maybe_build_local_admin_provider_strategy_response(
|
||||
state: &AppState,
|
||||
|
||||
+1
-22
@@ -1,10 +1,5 @@
|
||||
use crate::handlers::admin::shared::build_proxy_error_response;
|
||||
use axum::{
|
||||
body::Body,
|
||||
http,
|
||||
response::{IntoResponse, Response},
|
||||
Json,
|
||||
};
|
||||
use axum::{body::Body, http, response::Response};
|
||||
use serde_json::json;
|
||||
|
||||
pub(super) const ADMIN_PROVIDER_STRATEGY_DATA_UNAVAILABLE_DETAIL: &str =
|
||||
@@ -20,19 +15,3 @@ pub(super) fn admin_provider_strategy_data_unavailable_response(detail: &str) ->
|
||||
Some(json!({ "error": detail })),
|
||||
)
|
||||
}
|
||||
|
||||
pub(super) fn admin_provider_strategy_provider_not_found_response() -> Response<Body> {
|
||||
(
|
||||
http::StatusCode::NOT_FOUND,
|
||||
Json(json!({ "detail": "Provider not found" })),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
|
||||
pub(super) fn admin_provider_strategy_dispatcher_not_found_response() -> Response<Body> {
|
||||
(
|
||||
http::StatusCode::NOT_FOUND,
|
||||
Json(json!({ "detail": "Provider strategy route not found" })),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
@@ -3,15 +3,13 @@ use super::builders::{
|
||||
build_provider_strategy_stats_response, build_provider_strategy_update_billing_response,
|
||||
AdminProviderStrategyBillingRequest,
|
||||
};
|
||||
use super::shared::{
|
||||
use super::responses::{
|
||||
admin_provider_strategy_data_unavailable_response,
|
||||
admin_provider_strategy_dispatcher_not_found_response,
|
||||
admin_provider_strategy_provider_not_found_response,
|
||||
ADMIN_PROVIDER_STRATEGY_DATA_UNAVAILABLE_DETAIL,
|
||||
ADMIN_PROVIDER_STRATEGY_STATS_DATA_UNAVAILABLE_DETAIL,
|
||||
};
|
||||
use crate::control::GatewayPublicRequestContext;
|
||||
use crate::handlers::admin::provider::shared::{
|
||||
use crate::handlers::admin::provider::shared::paths::{
|
||||
admin_provider_id_for_provider_strategy_billing, admin_provider_id_for_provider_strategy_quota,
|
||||
admin_provider_id_for_provider_strategy_stats, is_admin_provider_strategy_strategies_root,
|
||||
};
|
||||
@@ -134,3 +132,19 @@ pub(super) async fn maybe_build_local_admin_provider_strategy_response(
|
||||
|
||||
Ok(Some(admin_provider_strategy_dispatcher_not_found_response()))
|
||||
}
|
||||
|
||||
fn admin_provider_strategy_provider_not_found_response() -> Response<Body> {
|
||||
(
|
||||
http::StatusCode::NOT_FOUND,
|
||||
Json(json!({ "detail": "Provider not found" })),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
|
||||
fn admin_provider_strategy_dispatcher_not_found_response() -> Response<Body> {
|
||||
(
|
||||
http::StatusCode::NOT_FOUND,
|
||||
Json(json!({ "detail": "Provider strategy route not found" })),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user