diff --git a/cmd/budgeteer/main.go b/cmd/budgeteer/main.go index 9564855..b78e28f 100644 --- a/cmd/budgeteer/main.go +++ b/cmd/budgeteer/main.go @@ -19,7 +19,7 @@ func main() { log.Fatalf("Could not load config: %v", err) } - q, err := postgres.Connect("pgx", cfg.DatabaseConnection) + queries, err := postgres.Connect("pgx", cfg.DatabaseConnection) if err != nil { log.Fatalf("Failed connecting to DB: %v", err) } @@ -30,7 +30,7 @@ func main() { } handler := &server.Handler{ - Service: q, + Service: queries, TokenVerifier: &jwt.TokenVerifier{}, CredentialsVerifier: &bcrypt.Verifier{}, StaticFS: http.FS(static), diff --git a/server/http.go b/server/http.go index 4437946..b28a7da 100644 --- a/server/http.go +++ b/server/http.go @@ -15,7 +15,7 @@ import ( "github.com/gin-gonic/gin" ) -// Handler handles incoming requests +// Handler handles incoming requests. type Handler struct { Service *postgres.Database TokenVerifier budgeteer.TokenVerifier @@ -23,7 +23,7 @@ type Handler struct { StaticFS http.FileSystem } -// Serve starts the http server +// Serve starts the http server. func (h *Handler) Serve() { router := gin.Default() h.LoadRoutes(router) @@ -33,7 +33,7 @@ func (h *Handler) Serve() { } } -// LoadRoutes initializes all the routes +// LoadRoutes initializes all the routes. func (h *Handler) LoadRoutes(router *gin.Engine) { router.Use(enableCachingForStaticFiles()) router.NoRoute(h.ServeStatic) @@ -73,6 +73,7 @@ func (h *Handler) LoadRoutes(router *gin.Engine) { transaction.POST("/new", h.newTransaction) transaction.POST("/:transactionid", h.newTransaction) } + func (h *Handler) ServeStatic(c *gin.Context) { h.ServeStaticFile(c, c.Request.URL.Path) }