//! plugin-apix —— API 代理插件。 //! //! 把外部 **API 供应商**的资产挂到网关下,复用 LLM 的 `sk_` 鉴权 + 配额 + //! 用量统计(slot 带 `api/` 前缀,天然归组)。数据文件 //! `data/api-proxies.json`(含供应商真 Key,敏感级别等同 users.json)。 //! //! ## 装配点(gateway) //! //! * `preconfig` —— 注册 `$apix_target` / `$apix_host` / `$apix_key` / //! `$apix_body` / `$apix_probe_target` / `$apix_probe_body` 六件套 //! * `postconfig` —— 注册 ApiProxyHandler(access 阶段) //! * `zone_load` —— 全量装载 `ax:` 代理表 //! * `dispatch_api` —— 认领 apix 管理端点与账号态端点 //! //! ## 依赖说明 //! //! 下行鉴权 / 配额在内核 `ipass_core::auth`;用量记账入口在 //! `plugin_llm::stats`(apix 与 LLM 共用同一片键空间,单一写入口防漂移)。 pub mod api; pub mod apix; pub mod config; pub mod handlers; pub mod models; pub mod store; use ngx::core::Status; use ngx::ffi::{ngx_conf_t, ngx_http_request_t}; use ipass_core::plugin::Plugin; pub struct ApixPlugin; impl Plugin for ApixPlugin { fn name(&self) -> &'static str { "apix" } fn preconfig(&self, cf: *mut ngx_conf_t) -> bool { // SAFETY: cf 由 nginx 传入且有效 unsafe { apix::preconfig(cf) } } fn postconfig(&self, cf: *mut ngx_conf_t) -> bool { // SAFETY: cf 由 nginx 传入且有效 ngx::http::add_phase_handler::(unsafe { &mut *cf }).is_ok() } fn dispatch_api(&self, r: *mut ngx_http_request_t) -> Option { api::dispatch(r) } fn zone_load(&self) -> usize { apix::reload_shm() } }