The menus can now be accessed from the handlers
Dieser Commit ist enthalten in:
Ursprung
a1b11a6adb
Commit
37e8ac835e
|
@ -0,0 +1,7 @@
|
|||
package httpserver
|
||||
|
||||
// These are constants to have an single point to look up static items
|
||||
const (
|
||||
Accounts = "account"
|
||||
Menus = "menu"
|
||||
)
|
12
http.go
12
http.go
|
@ -64,9 +64,13 @@ func CreateServer(config *toml.Tree) *Server {
|
|||
router: gin.New(),
|
||||
authhf: &auth.AnonAccountHandler{},
|
||||
}
|
||||
server.Use(func(c *gin.Context) {
|
||||
c.Set("account", server.authhf.Account(c))
|
||||
})
|
||||
mw := []gin.HandlerFunc{
|
||||
func(c *gin.Context) {
|
||||
c.Set(Accounts, server.authhf.Account(c))
|
||||
c.Set(Menus, server.menus)
|
||||
},
|
||||
}
|
||||
server.Use(mw...)
|
||||
if err := config.Unmarshal(server.conf); err != nil {
|
||||
log.Error().Msg("Problem mapping config to Configstruct")
|
||||
}
|
||||
|
@ -79,7 +83,7 @@ func CreateServer(config *toml.Tree) *Server {
|
|||
}
|
||||
server.router.NoRoute(gin.WrapH(http.NotFoundHandler()))
|
||||
gin.DebugPrintRouteFunc = func(httpMethod, absolutePath, handlerName string, nuHandlers int) {
|
||||
log.Trace().Msgf("%-4s(%02d): %-20s %s", httpMethod, nuHandlers-1, absolutePath, handlerName)
|
||||
log.Trace().Msgf("%-4s(%02d): %-20s %s", httpMethod, nuHandlers-len(mw), absolutePath, handlerName)
|
||||
}
|
||||
server.menus = []menus.Menu{}
|
||||
return server
|
||||
|
|
Laden…
In neuem Issue referenzieren