1package routes
2
3import (
4 "git.sr.ht/~gabrielgio/midr/controller"
5 "git.sr.ht/~gabrielgio/midr/db"
6 "github.com/gin-gonic/gin"
7)
8
9func HandleRequests() {
10
11 env := &controller.Env{
12 Entries: db.EntryModel{DB: db.DB},
13 }
14
15 r := gin.Default()
16 r.LoadHTMLGlob("templates/*")
17 r.GET("/", env.GetEntries)
18 r.GET("entries/", env.GetEntry)
19 r.POST("entries/", env.CreateEntry)
20 r.GET("entries/:id", env.GetEntry)
21 r.POST("entries/:id", env.UpdateEntry)
22 r.DELETE("entries/:id", env.DeleteEntry)
23 r.Run(":8000")
24}