feat(routing): GET/POST /v1/me/routing 端点 + openapi

This commit is contained in:
wangjia
2026-07-28 07:49:03 +08:00
parent 3a2c48541c
commit 49f62d9b14
5 changed files with 455 additions and 0 deletions
+121
View File
@@ -217,6 +217,83 @@ components:
minutes_used:
type: integer
RoutingRule:
type: object
required: [type, value, action, enabled]
properties:
type:
type: string
enum: [domain, domain_suffix, domain_keyword, ip_cidr, geoip, geosite]
value:
type: string
description: geoip/geosite 目前仅白名单 cn(自托管规则集);ip_cidr 需合法 CIDR
example: x.com
action:
type: string
enum: [direct, proxy, reject]
note:
type: string
enabled:
type: boolean
RoutingBuiltin:
type: object
properties:
china_direct:
type: boolean
description: 国内域名/IP 直连
lan_direct:
type: boolean
description: 局域网直连
private_via_tunnel:
type: boolean
description: 私有服务域名强制走隧道(家庭内网穿透场景)
RoutingProfile:
type: object
required: [mode, builtin, rules, final]
properties:
mode:
type: string
enum: [rule, global, direct]
builtin:
$ref: '#/components/schemas/RoutingBuiltin'
rules:
type: array
maxItems: 200
items:
$ref: '#/components/schemas/RoutingRule'
final:
type: string
enum: [proxy, direct]
RoutingValidationError:
type: object
required: [code, message_zh, message_en, errors]
properties:
code:
type: string
example: routing_invalid
message_zh:
type: string
example: 规则校验未通过
message_en:
type: string
example: Rule validation failed
errors:
type: array
items:
type: object
required: [index, field, reason]
properties:
index:
type: integer
description: -1 表示档案级字段(mode/final/rules 数量),否则为 rules 下标
field:
type: string
reason:
type: string
paths:
# ── Auth ──────────────────────────────────────────────────────────────────
@@ -418,6 +495,50 @@ paths:
schema:
$ref: '#/components/schemas/Error'
/me/routing:
get:
summary: 获取当前用户的分流配置(可配置分流;未自定义时返回默认档案)
responses:
'200':
description: 分流档案
content:
application/json:
schema:
$ref: '#/components/schemas/RoutingProfile'
'401':
description: 未认证
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
summary: 保存当前用户的分流配置(整份覆盖;校验失败不部分保存)
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RoutingProfile'
responses:
'200':
description: 保存成功,返回规整化后的档案
content:
application/json:
schema:
$ref: '#/components/schemas/RoutingProfile'
'400':
description: 校验失败(逐条错误,不部分保存)
content:
application/json:
schema:
$ref: '#/components/schemas/RoutingValidationError'
'401':
description: 未认证
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
# ── Plans & Subscriptions ─────────────────────────────────────────────────
/plans: