Extract loading of accounts to middleware

This commit is contained in:
2021-12-04 22:47:01 +00:00
parent e30fab6a06
commit 6628a4849f
3 changed files with 40 additions and 23 deletions

View File

@ -46,15 +46,16 @@ func (h *Handler) Serve() {
router.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index.html", nil) })
router.GET("/login", h.login)
router.GET("/register", h.register)
authenticatedFrontend := router.Group("")
withBudget := router.Group("")
{
authenticatedFrontend.Use(h.verifyLoginWithRedirect)
authenticatedFrontend.GET("/dashboard", h.dashboard)
authenticatedFrontend.GET("/budget/:budgetid", h.budget)
authenticatedFrontend.GET("/budget/:budgetid/accounts", h.accounts)
authenticatedFrontend.GET("/account/:accountid", h.account)
authenticatedFrontend.GET("/admin", h.admin)
authenticatedFrontend.GET("/admin/clear-database", h.clearDatabase)
withBudget.Use(h.verifyLoginWithRedirect)
withBudget.Use(h.getImportantData)
withBudget.GET("/dashboard", h.dashboard)
withBudget.GET("/budget/:budgetid", h.budget)
withBudget.GET("/budget/:budgetid/accounts", h.accounts)
withBudget.GET("/account/:accountid", h.account)
withBudget.GET("/admin", h.admin)
withBudget.GET("/admin/clear-database", h.clearDatabase)
}
api := router.Group("/api/v1")
{