fix: configure middlewares before groups

This commit is contained in:
Stavros
2025-08-26 13:17:10 +03:00
parent 77296daef3
commit 8435cbe434
3 changed files with 10 additions and 6 deletions

View File

@@ -148,9 +148,6 @@ func (app *BootstrapApp) Setup() error {
gin.SetMode(gin.ReleaseMode)
}
router := engine.Group("/")
apiRouter := router.Group("/api")
// Create middlewares
var middlewares []Middleware
@@ -169,9 +166,13 @@ func (app *BootstrapApp) Setup() error {
if err != nil {
return fmt.Errorf("failed to initialize %s middleware: %T", middleware, err)
}
router.Use(middleware.Middleware())
engine.Use(middleware.Middleware())
}
// Create routers
mainRouter := engine.Group("/")
apiRouter := engine.Group("/api")
// Create controllers
contextController := controller.NewContextController(controller.ContextControllerConfig{
ConfiguredProviders: configuredProviders,
@@ -201,7 +202,7 @@ func (app *BootstrapApp) Setup() error {
resourcesController := controller.NewResourcesController(controller.ResourcesControllerConfig{
ResourcesDir: app.Config.ResourcesDir,
}, router)
}, mainRouter)
healthController := controller.NewHealthController(apiRouter)

View File

@@ -38,7 +38,7 @@ func NewProxyController(config ProxyControllerConfig, router *gin.RouterGroup, d
}
func (controller *ProxyController) SetupRoutes() {
proxyGroup := controller.Router.Group("/api/auth")
proxyGroup := controller.Router.Group("/auth")
proxyGroup.GET("/:proxy", controller.proxyHandler)
}

View File

@@ -30,6 +30,9 @@ func (docker *DockerService) Init() error {
ctx := context.Background()
client.NegotiateAPIVersion(ctx)
docker.Client = client
docker.Context = ctx
return nil
}