diff --git a/http/http.go b/http/http.go index 745e60b..53870b4 100644 --- a/http/http.go +++ b/http/http.go @@ -4,7 +4,6 @@ import ( "io/fs" "net/http" "strings" - "time" "git.javil.eu/jacob1123/budgeteer" "git.javil.eu/jacob1123/budgeteer/bcrypt" @@ -25,11 +24,15 @@ const ( expiration = 72 ) -// Serve starts the HTTP Server +// Serve starts the http server func (h *Handler) Serve() { router := gin.Default() - router.FuncMap["now"] = time.Now + h.LoadRoutes(router) + router.Run(":1323") +} +// LoadRoutes initializes all the routes +func (h *Handler) LoadRoutes(router *gin.Engine) { static, err := fs.Sub(web.Static, "dist") if err != nil { panic("couldn't open static files") @@ -77,8 +80,6 @@ func (h *Handler) Serve() { transaction := authenticated.Group("/transaction") transaction.POST("/new", h.newTransaction) transaction.POST("/:transactionid", h.newTransaction) - - router.Run(":1323") } func enableCachingForStaticFiles() gin.HandlerFunc {