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