fix(运行时): 将插件路径匹配移到宿主

新增宿主侧精确路径匹配和插件级 match.paths 配置。\n按请求路径固定插件会话链,移除 Lua 插件内的路径判断与 bypass 状态,并迁移现有插件配置和测试。
This commit is contained in:
starrrLight committed 2026-10-15 15:49:05 +08:00
1 parent f905aa22cc
commit d1f5f69454
12 files changed
+126 -200

No files matched your search

+16
View File
@@ -16,6 +16,22 @@ return plugin
`ctx` 包含中间层生成的 `request_id` 和当前 `plugin_id`。它不是用户身份或授权证据。每次钩子获得数据副本,需通过返回值传递修改。插件用模块局部变量保存本请求状态;不同插件、不同请求均不共享全局变量。
## 路径匹配
插件是否参与一次请求由宿主根据插件级 `match.paths` 决定,Lua 插件不再读取或维护路径白名单和 `bypass` 状态。一次请求创建会话时完成匹配,后续的 `on_request`、`on_response`、`on_event`、`on_end` 和 `close` 始终使用同一组插件。
```yaml
plugins:
- id: request-rewrite
file: plugins/request_rewrite.lua
match:
paths: [/chat/stream]
config:
prefix: "[checked] "
```
`match.paths` 是精确路径列表,区分大小写和尾斜杠,不支持前缀、通配符、查询参数或正则。省略 `match` 表示匹配所有路径。旧的 `config.paths` 已移除,启动时会报错并要求迁移到 `match.paths`。
## 钩子数据
| 钩子 | 第二参数 | 可以返回的动作 |