Extract LoadRoutes method
This commit is contained in:
parent
922041856f
commit
c3a1564c4e
11
http/http.go
11
http/http.go
@ -4,7 +4,6 @@ import (
|
|||||||
"io/fs"
|
"io/fs"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"git.javil.eu/jacob1123/budgeteer"
|
"git.javil.eu/jacob1123/budgeteer"
|
||||||
"git.javil.eu/jacob1123/budgeteer/bcrypt"
|
"git.javil.eu/jacob1123/budgeteer/bcrypt"
|
||||||
@ -25,11 +24,15 @@ const (
|
|||||||
expiration = 72
|
expiration = 72
|
||||||
)
|
)
|
||||||
|
|
||||||
// Serve starts the HTTP Server
|
// Serve starts the http server
|
||||||
func (h *Handler) Serve() {
|
func (h *Handler) Serve() {
|
||||||
router := gin.Default()
|
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")
|
static, err := fs.Sub(web.Static, "dist")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("couldn't open static files")
|
panic("couldn't open static files")
|
||||||
@ -77,8 +80,6 @@ func (h *Handler) Serve() {
|
|||||||
transaction := authenticated.Group("/transaction")
|
transaction := authenticated.Group("/transaction")
|
||||||
transaction.POST("/new", h.newTransaction)
|
transaction.POST("/new", h.newTransaction)
|
||||||
transaction.POST("/:transactionid", h.newTransaction)
|
transaction.POST("/:transactionid", h.newTransaction)
|
||||||
|
|
||||||
router.Run(":1323")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func enableCachingForStaticFiles() gin.HandlerFunc {
|
func enableCachingForStaticFiles() gin.HandlerFunc {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user