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

+31
View File
@@ -57,6 +57,37 @@ async def test_chain_isolation_json_and_disabled(tmp_path):
assert not manager.sessions
async def test_host_selects_plugins_once_by_exact_path(tmp_path):
first = tmp_path / "first.lua"
second = tmp_path / "second.lua"
first.write_text(
"return {on_request=function(ctx,r) r.body=r.body..' first'; return {action='replace',value=r} end}",
encoding="utf-8",
)
second.write_text(
"return {on_request=function(ctx,r) r.body=r.body..' second'; return {action='replace',value=r} end}",
encoding="utf-8",
)
settings = Settings(
upstream="http://agent:8000",
plugins=[
PluginConfig(id="first", file=first, match={"paths": ["/first"]}),
PluginConfig(id="second", file=second, match={"paths": ["/second"]}),
],
)
manager = PluginManager(settings)
first_session = await manager.open(path="/first")
try:
assert await first_session.apply("on_request", {"body": "x"}) == [{"body": "x first"}]
finally:
await first_session.aclose()
second_session = await manager.open(path="/second?ignored=true")
try:
assert await second_session.apply("on_request", {"body": "x"}) == [{"body": "x"}]
finally:
await second_session.aclose()
async def test_hold_flush_runs_downstream(tmp_path):
manager = manager_for(
tmp_path,