@@ -20,7 +20,6 @@ type Controller interface {
2020type Middleware interface {
2121 Middleware () gin.HandlerFunc
2222 Init () error
23- Name () string
2423}
2524
2625type Service interface {
@@ -103,6 +102,7 @@ func (app *BootstrapApp) Setup() error {
103102 err := ldapService .Init ()
104103
105104 if err != nil {
105+ log .Warn ().Err (err ).Msg ("Failed to initialize LDAP service, continuing without LDAP" )
106106 ldapService = nil
107107 }
108108 }
@@ -120,6 +120,7 @@ func (app *BootstrapApp) Setup() error {
120120
121121 for _ , svc := range services {
122122 if svc != nil {
123+ log .Debug ().Str ("service" , fmt .Sprintf ("%T" , svc )).Msg ("Initializing service" )
123124 err := svc .Init ()
124125 if err != nil {
125126 return err
@@ -142,7 +143,13 @@ func (app *BootstrapApp) Setup() error {
142143
143144 // Create engine
144145 engine := gin .New ()
145- router := engine .Group ("/api" )
146+
147+ if config .Version != "development" {
148+ gin .SetMode (gin .ReleaseMode )
149+ }
150+
151+ router := engine .Group ("/" )
152+ apiRouter := router .Group ("/api" )
146153
147154 // Create middlewares
148155 var middlewares []Middleware
@@ -151,18 +158,16 @@ func (app *BootstrapApp) Setup() error {
151158 Domain : domain ,
152159 }, authService , oauthBrokerService )
153160
154- uiMiddleware := middleware .NewUIMiddleware (middleware.UIMiddlewareConfig {
155- ResourcesDir : app .Config .ResourcesDir ,
156- })
161+ uiMiddleware := middleware .NewUIMiddleware ()
157162 zerologMiddleware := middleware .NewZerologMiddleware ()
158163
159164 middlewares = append (middlewares , contextMiddleware , uiMiddleware , zerologMiddleware )
160165
161166 for _ , middleware := range middlewares {
162- log .Debug ().Str ("middleware" , middleware . Name ( )).Msg ("Initializing middleware" )
167+ log .Debug ().Str ("middleware" , fmt . Sprintf ( "%T" , middleware )).Msg ("Initializing middleware" )
163168 err := middleware .Init ()
164169 if err != nil {
165- return fmt .Errorf ("failed to initialize %s middleware: %w " , middleware . Name () , err )
170+ return fmt .Errorf ("failed to initialize %s middleware: %T " , middleware , err )
166171 }
167172 router .Use (middleware .Middleware ())
168173 }
@@ -177,24 +182,28 @@ func (app *BootstrapApp) Setup() error {
177182 ForgotPasswordMessage : app .Config .FogotPasswordMessage ,
178183 BackgroundImage : app .Config .BackgroundImage ,
179184 OAuthAutoRedirect : app .Config .OAuthAutoRedirect ,
180- }, router )
185+ }, apiRouter )
181186
182187 oauthController := controller .NewOAuthController (controller.OAuthControllerConfig {
183188 AppURL : app .Config .AppURL ,
184189 SecureCookie : app .Config .SecureCookie ,
185190 CSRFCookieName : csrfCookieName ,
186191 RedirectCookieName : redirectCookieName ,
187- }, router , authService , oauthBrokerService )
192+ }, apiRouter , authService , oauthBrokerService )
188193
189194 proxyController := controller .NewProxyController (controller.ProxyControllerConfig {
190195 AppURL : app .Config .AppURL ,
191- }, router , dockerService , authService )
196+ }, apiRouter , dockerService , authService )
192197
193198 userController := controller .NewUserController (controller.UserControllerConfig {
194199 Domain : domain ,
195- }, router , authService )
200+ }, apiRouter , authService )
201+
202+ resourcesController := controller .NewResourcesController (controller.ResourcesControllerConfig {
203+ ResourcesDir : app .Config .ResourcesDir ,
204+ }, router )
196205
197- healthController := controller .NewHealthController (router )
206+ healthController := controller .NewHealthController (apiRouter )
198207
199208 // Setup routes
200209 controller := []Controller {
@@ -203,10 +212,11 @@ func (app *BootstrapApp) Setup() error {
203212 proxyController ,
204213 userController ,
205214 healthController ,
215+ resourcesController ,
206216 }
207217
208218 for _ , ctrl := range controller {
209- log .Debug ().Msgf ("Setting up %T routes " , ctrl )
219+ log .Debug ().Msgf ("Setting up %T controller " , ctrl )
210220 ctrl .SetupRoutes ()
211221 }
212222
0 commit comments