c2354f855f
新增 llm_router_account 表、procedures 与客户端绑定 api-server 改为 New API 管理员流程签发独立 Router 账号 Router 成功后执行幂等后置泥点扣费 生产外锁定非生产 Router 控制面为 loopback AGC 正式模式清除手工 Provider 凭据并锁定官方代理 AGC 状态面只返回账号凭据与官方路由安全元数据 后台数据库表查询适配账号凭据状态展示 补充 AGC 与后端测试、环境示例和架构文档 修正 dev-stack 状态路径按仓库脚本位置解析
147 lines
5.1 KiB
Rust
147 lines
5.1 KiB
Rust
use axum::{
|
|
Router, middleware,
|
|
routing::{delete, get, patch, post},
|
|
};
|
|
|
|
use crate::{
|
|
auth::require_bearer_auth,
|
|
external_api_keys::{
|
|
create_external_api_key, ensure_llm_router_api_key, list_external_api_keys,
|
|
revoke_external_api_key,
|
|
},
|
|
profile_identity::update_profile_identity,
|
|
runtime_profile::{
|
|
claim_profile_task_reward, confirm_wechat_profile_recharge_order,
|
|
create_profile_recharge_order, get_profile_analytics_metric, get_profile_dashboard,
|
|
get_profile_recharge_center, get_profile_referral_invite_center, get_profile_task_center,
|
|
get_profile_wallet_ledger, redeem_profile_referral_invite_code, redeem_profile_reward_code,
|
|
stream_wechat_profile_recharge_order_events, submit_profile_feedback,
|
|
},
|
|
state::AppState,
|
|
};
|
|
|
|
pub fn router(state: AppState) -> Router<AppState> {
|
|
Router::new()
|
|
.route(
|
|
"/api/profile/me",
|
|
patch(update_profile_identity).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/dashboard",
|
|
get(get_profile_dashboard).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/api-keys/llm-router",
|
|
post(ensure_llm_router_api_key).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/api-keys",
|
|
get(list_external_api_keys)
|
|
.post(create_external_api_key)
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/api-keys/{key_id}",
|
|
delete(revoke_external_api_key).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/wallet-ledger",
|
|
get(get_profile_wallet_ledger).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/recharge-center",
|
|
get(get_profile_recharge_center).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/recharge/orders",
|
|
post(create_profile_recharge_order).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/recharge/orders/{order_id}/wechat/confirm",
|
|
post(confirm_wechat_profile_recharge_order).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_bearer_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/api/profile/recharge/orders/{order_id}/wechat/events",
|
|
get(stream_wechat_profile_recharge_order_events).route_layer(
|
|
middleware::from_fn_with_state(state.clone(), require_bearer_auth),
|
|
),
|
|
)
|
|
.route(
|
|
"/api/profile/feedback",
|
|
post(submit_profile_feedback)
|
|
.layer(axum::extract::DefaultBodyLimit::max(6 * 1024 * 1024))
|
|
.route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/referrals/invite-center",
|
|
get(get_profile_referral_invite_center).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/referrals/redeem-code",
|
|
post(redeem_profile_referral_invite_code).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/redeem-codes/redeem",
|
|
post(redeem_profile_reward_code).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/analytics/metric",
|
|
get(get_profile_analytics_metric).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/tasks",
|
|
get(get_profile_task_center).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
.route(
|
|
"/api/profile/tasks/{task_id}/claim",
|
|
post(claim_profile_task_reward).route_layer(middleware::from_fn_with_state(
|
|
state.clone(),
|
|
require_bearer_auth,
|
|
)),
|
|
)
|
|
}
|