From da992500f806bb87b06559d920ee12b7680955ee Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Thu, 16 Jun 2022 16:32:31 +0200 Subject: feat: Add worker Add a simple worker to manage a work queue. Right now, it is bit brittled and has no test coverage yet, but it works. Also moved from pico.css to bulma, I like the idea of classes approach of pico but for me bulma yields a better result. --- routes/routes.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'routes/routes.go') diff --git a/routes/routes.go b/routes/routes.go index a960277..a609019 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -3,19 +3,28 @@ package routes import ( "git.sr.ht/~gabrielgio/midr/controller" "git.sr.ht/~gabrielgio/midr/db" + "git.sr.ht/~gabrielgio/midr/worker" "github.com/gin-gonic/gin" ) func HandleRequests() { + models := db.EntryModel{DB: db.DB} + worker := worker.Worker{} + + worker.StartWorker(models) + env := &controller.Env{ - Entries: db.EntryModel{DB: db.DB}, + Entries: models, + Worker: worker, } r := gin.Default() r.LoadHTMLGlob("templates/*") + r.Static("/assets", "./assets") r.GET("/", env.GetEntries) - r.GET("entries/", env.GetEntry) + r.GET("/entries/", env.GetEntries) + r.GET("entries/createEntry", env.GetEntry) r.POST("entries/", env.CreateEntry) r.GET("entries/:id", env.GetEntry) r.POST("entries/:id", env.UpdateEntry) -- cgit v1.2.3