feat(gateway): wire plugin toggle (load+set_current+dispatch skip); short-name config keys (R19)
- postconfiguration loads <data_dir>/plugin-config.json into registry - disabled plugins claim no /api routes (404 fallback); core never skipped - data-seed keys + admin_prefix now Plugin::name() short names - collect-plugin-dist.sh: normalize keys, resolve ipass-plugin-<short> dirs, emit <short>-admin.umd.js alias matching loader.ts protocol Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
bf2528de0f
commit
359a67b657
3 files changed
+37
-12
No files matched your search
@@ -225,6 +225,11 @@ fn loc_switch(request: &mut Request, s: Switch) -> bool {
|
||||
/// 管理 API 分发:按 PLUGINS 顺序问每个插件,都不认领才统一 404。
|
||||
fn dispatch_api(r: *mut ngx_http_request_t) -> Status {
|
||||
for p in PLUGINS {
|
||||
// R19:被禁插件不认领路由(自然落到下面的统一 404)。
|
||||
// core 是网关身份底座,永不跳过;gateway-routes(trend)不在注册表内,恒启用。
|
||||
if p.name() != "core" && !ipass_core::plugin_registry::plugin_enabled(p.name()) {
|
||||
continue;
|
||||
}
|
||||
if let Some(s) = p.dispatch_api(r) {
|
||||
return s;
|
||||
}
|
||||
@@ -353,6 +358,14 @@ impl HttpModule for Module {
|
||||
unsafe extern "C" fn postconfiguration(cf: *mut ngx_conf_t) -> ngx_int_t {
|
||||
let cf = unsafe { &mut *cf };
|
||||
|
||||
// R19:装载插件启停注册表。`ipass_data_dir` 指令在配置解析阶段已写入
|
||||
// store;postconfiguration 在 master 单次执行(reload 重进 = 热更新)。
|
||||
let cfg = ipass_core::plugin_registry::load(&format!(
|
||||
"{}/plugin-config.json",
|
||||
store::data_dir()
|
||||
));
|
||||
ipass_core::plugin_registry::set_current(cfg);
|
||||
|
||||
// 把本模块 ctx_index 注入内核契约:插件在 r->ctx 上挂请求级状态
|
||||
// (如 ipass-plugin-llm 的 usage_filter 扫描窗口)用它定位自己的槽位
|
||||
ipass_core::plugin::set_ctx_index(Module::module().ctx_index as usize);
|
||||
|
||||
Reference in new issue
Block a user