fix: 插件路由注册 — 通过 fx 依赖注入确保插件构造并注册路由
Some checks failed
CI / Build & Test (push) Failing after 1m31s

- newEngine 接收 *ExamplePlugin 强制 fx 构造插件实例
- 直接调用 examplePlugin.SetupRoutes 注册路由
- 移除 plugin.All() 循环(避免双重注册)
This commit is contained in:
MengStack Dev 2026-10-03 02:10:45 +08:00
parent 7ad62c7488
commit 70a5e3ffaf

View File

@ -49,6 +49,7 @@ func newEngine(
auditHandler *auditinterfaces.Handler,
settingsHandler *settingsinterfaces.Handler,
notificationHandler *notificationinterfaces.Handler,
examplePlugin *exampleinterfaces.ExamplePlugin,
) *gin.Engine {
ginMode := "release"
if cfg.Server.Mode == "debug" || cfg.Server.Mode == "dev" {
@ -77,9 +78,7 @@ func newEngine(
settingsinterfaces.SetupRoutes(r, settingsHandler, authMW)
notificationinterfaces.SetupRoutes(r, notificationHandler, authMW)
for _, p := range plugin.All() {
p.SetupRoutes(r, authMW)
}
examplePlugin.SetupRoutes(r, authMW)
return r
}