aboutsummaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/routes.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/routes/routes.go b/routes/routes.go
index d78acc7..a960277 100644
--- a/routes/routes.go
+++ b/routes/routes.go
@@ -2,17 +2,23 @@ package routes
import (
"git.sr.ht/~gabrielgio/midr/controller"
+ "git.sr.ht/~gabrielgio/midr/db"
"github.com/gin-gonic/gin"
)
func HandleRequests() {
+
+ env := &controller.Env{
+ Entries: db.EntryModel{DB: db.DB},
+ }
+
r := gin.Default()
r.LoadHTMLGlob("templates/*")
- r.GET("/", controller.GetEntries)
- r.GET("entries/", controller.GetEntry)
- r.POST("entries/", controller.CreateEntry)
- r.GET("entries/:id", controller.GetEntry)
- r.POST("entries/:id", controller.UpdateEntry)
- r.DELETE("entries/:id", controller.DeleteEntry)
+ r.GET("/", env.GetEntries)
+ r.GET("entries/", env.GetEntry)
+ r.POST("entries/", env.CreateEntry)
+ r.GET("entries/:id", env.GetEntry)
+ r.POST("entries/:id", env.UpdateEntry)
+ r.DELETE("entries/:id", env.DeleteEntry)
r.Run(":8000")
}