1
0

Updated handler config (#63)

This commit is contained in:
konrad
2019-03-24 09:13:40 +00:00
committed by Gitea
parent 1dc14d5ddf
commit 11e7c071ce
118 changed files with 3675 additions and 1235 deletions

View File

@ -105,6 +105,14 @@ func NewEcho() *echo.Echo {
// Validation
e.Validator = &CustomValidator{}
// Handler config
handler.SetAuthProvider(&web.Auths{
AuthObject: func(c echo.Context) (web.Auth, error) {
return models.GetCurrentUser(c)
},
})
handler.SetLoggingProvider(log.Log)
return e
}
@ -189,19 +197,6 @@ func RegisterRoutes(e *echo.Echo) {
// Authetification
a.Use(middleware.JWT([]byte(viper.GetString("service.JWTSecret"))))
// Put the authprovider in the context to be able to use it later
e.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
c.Set("AuthProvider", &web.Auths{
AuthObject: func(echo.Context) (web.Auth, error) {
return models.GetCurrentUser(c)
},
})
c.Set("LoggingProvider", log.Log)
return next(c)
}
})
// Middleware to collect metrics
if viper.GetBool("service.enablemetrics") {
a.Use(func(next echo.HandlerFunc) echo.HandlerFunc {