midr @ 90d9d819b70f68e10482954cfc461737c0165f8a

 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.NewWorkder()
14
15	env := &controller.Env{
16		Entries: models,
17		Worker:  worker,
18	}
19
20	env.StartScheduler()
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.GET("jobs/", env.GetJobs)
33	r.Run(":8000")
34}