aboutsummaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2022-06-16 16:32:31 +0200
committerGabriel A. Giovanini <mail@gabrielgio.me>2022-06-16 16:32:31 +0200
commitda992500f806bb87b06559d920ee12b7680955ee (patch)
treed535f986eba7a95e5cb6b358259bc37ca6fa7ca9 /routes
parent64496464b3812839c1e4b440bdf69cc84f39c491 (diff)
downloadmdir-da992500f806bb87b06559d920ee12b7680955ee.tar.gz
mdir-da992500f806bb87b06559d920ee12b7680955ee.tar.bz2
mdir-da992500f806bb87b06559d920ee12b7680955ee.zip
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.
Diffstat (limited to 'routes')
-rw-r--r--routes/routes.go13
1 files changed, 11 insertions, 2 deletions
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)