Reorganize routes
This commit is contained in:
parent
95f6e95fdd
commit
69bac9bc3f
33
http/http.go
33
http/http.go
@ -46,45 +46,36 @@ func (h *Handler) Serve() {
|
|||||||
router.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index.html", nil) })
|
router.GET("/", func(c *gin.Context) { c.HTML(http.StatusOK, "index.html", nil) })
|
||||||
router.GET("/login", h.login)
|
router.GET("/login", h.login)
|
||||||
router.GET("/register", h.register)
|
router.GET("/register", h.register)
|
||||||
|
router.Group("").Use(h.verifyLoginWithRedirect).GET("/dashboard", h.dashboard)
|
||||||
|
|
||||||
withBudget := router.Group("")
|
withBudget := router.Group("")
|
||||||
{
|
|
||||||
withBudget.Use(h.verifyLoginWithRedirect)
|
withBudget.Use(h.verifyLoginWithRedirect)
|
||||||
withBudget.Use(h.getImportantData)
|
withBudget.Use(h.getImportantData)
|
||||||
withBudget.GET("/dashboard", h.dashboard)
|
|
||||||
withBudget.GET("/budget/:budgetid", h.budget)
|
withBudget.GET("/budget/:budgetid", h.budget)
|
||||||
withBudget.GET("/budget/:budgetid/accounts", h.accounts)
|
withBudget.GET("/budget/:budgetid/accounts", h.accounts)
|
||||||
withBudget.GET("/budget/:budgetid/account/:accountid", h.account)
|
withBudget.GET("/budget/:budgetid/account/:accountid", h.account)
|
||||||
withBudget.GET("/admin", h.admin)
|
withBudget.GET("/admin", h.admin)
|
||||||
withBudget.GET("/admin/clear-database", h.clearDatabase)
|
withBudget.GET("/admin/clear-database", h.clearDatabase)
|
||||||
}
|
|
||||||
api := router.Group("/api/v1")
|
api := router.Group("/api/v1")
|
||||||
{
|
|
||||||
user := api.Group("/user")
|
unauthenticated := api.Group("/user")
|
||||||
{
|
|
||||||
unauthenticated := user.Group("")
|
|
||||||
{
|
|
||||||
unauthenticated.GET("/login", func(c *gin.Context) { c.Redirect(http.StatusPermanentRedirect, "/login") })
|
unauthenticated.GET("/login", func(c *gin.Context) { c.Redirect(http.StatusPermanentRedirect, "/login") })
|
||||||
unauthenticated.POST("/login", h.loginPost)
|
unauthenticated.POST("/login", h.loginPost)
|
||||||
unauthenticated.POST("/register", h.registerPost)
|
unauthenticated.POST("/register", h.registerPost)
|
||||||
}
|
|
||||||
authenticated := user.Group("")
|
authenticated := api.Group("")
|
||||||
{
|
|
||||||
authenticated.Use(h.verifyLoginWithRedirect)
|
authenticated.Use(h.verifyLoginWithRedirect)
|
||||||
authenticated.GET("/logout", logout)
|
|
||||||
}
|
user := authenticated.Group("/user")
|
||||||
}
|
user.GET("/logout", logout)
|
||||||
|
|
||||||
budget := api.Group("/budget")
|
budget := api.Group("/budget")
|
||||||
{
|
|
||||||
budget.Use(h.verifyLoginWithRedirect)
|
|
||||||
budget.POST("/new", h.newBudget)
|
budget.POST("/new", h.newBudget)
|
||||||
}
|
|
||||||
transaction := api.Group("/transaction")
|
transaction := api.Group("/transaction")
|
||||||
{
|
|
||||||
transaction.Use(h.verifyLoginWithRedirect)
|
|
||||||
transaction.POST("/new", h.newTransaction)
|
transaction.POST("/new", h.newTransaction)
|
||||||
transaction.POST("/import/ynab", h.importYNAB)
|
transaction.POST("/import/ynab", h.importYNAB)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
router.Run(":1323")
|
router.Run(":1323")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user