95d6bc2ae7
新增外部编辑器 OpenAPI 路由与 openapi.json 导出 新增账号级 API Key 表、鉴权、创建、列表和撤销链路 新增个人中心开发者 API Key 管理弹窗 补充前端契约、客户端方法、测试与项目文档
137 lines
4.8 KiB
Rust
137 lines
4.8 KiB
Rust
use axum::{
|
|
Router, middleware,
|
|
routing::{delete, get, patch, post},
|
|
};
|
|
|
|
use crate::{
|
|
auth::require_bearer_auth,
|
|
external_api_keys::{create_external_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",
|
|
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,
|
|
)),
|
|
)
|
|
}
|