aboutsummaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-rw-r--r--routes/routes.go13
1 files changed, 10 insertions, 3 deletions
diff --git a/routes/routes.go b/routes/routes.go
index 31384a7..873c6c9 100644
--- a/routes/routes.go
+++ b/routes/routes.go
@@ -1,13 +1,17 @@
package routes
import (
+ "embed"
+ "html/template"
+ "net/http"
+
"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() {
+func HandleRequests(f embed.FS) {
models := db.EntryModel{DB: db.DB}
worker := worker.NewWorkder()
@@ -20,8 +24,11 @@ func HandleRequests() {
env.StartScheduler()
r := gin.Default()
- r.LoadHTMLGlob("templates/*")
- r.Static("/assets", "./assets")
+
+ templ := template.Must(template.New("").ParseFS(f, "templates/*.tmpl"))
+ r.SetHTMLTemplate(templ)
+ r.StaticFS("/p", http.FS(f))
+
r.GET("/", env.GetEntries)
r.GET("/entries/", env.GetEntries)
r.GET("entries/createEntry", env.GetEntry)