fix: address project audit gaps
This commit is contained in:
@@ -7,7 +7,11 @@ import (
|
||||
"senlinai-agent/backend/internal/config"
|
||||
)
|
||||
|
||||
func NewRouter(cfg config.Config) *gin.Engine {
|
||||
type RouteRegistrar interface {
|
||||
Register(router gin.IRouter)
|
||||
}
|
||||
|
||||
func NewRouter(cfg config.Config, registrars ...RouteRegistrar) *gin.Engine {
|
||||
if cfg.Env == "test" {
|
||||
gin.SetMode(gin.TestMode)
|
||||
}
|
||||
@@ -18,6 +22,10 @@ func NewRouter(cfg config.Config) *gin.Engine {
|
||||
router.GET("/healthz", func(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"status": "ok"})
|
||||
})
|
||||
api := router.Group("/api")
|
||||
for _, registrar := range registrars {
|
||||
registrar.Register(api)
|
||||
}
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user