Tinkering with how to do a 'check view, then static' style of templates, but maybe I need to do a generator?

This commit is contained in:
Zed A. Shaw 2025-06-29 22:47:03 -04:00
parent abc9fbda2e
commit b9d5dbb2e9
3 changed files with 20 additions and 11 deletions

View file

@ -2,6 +2,7 @@ package api
import (
"log"
"time"
"github.com/gofiber/fiber/v2"
_ "github.com/mattn/go-sqlite3"
@ -112,6 +113,23 @@ func PostApiLink(c *fiber.Ctx) error {
func Setup(app *fiber.App) {
STORE = session.New()
app.Static("/", "./public", fiber.Static{
Compress: false,
CacheDuration: 1 * time.Nanosecond,
Next: func(c *fiber.Ctx) bool {
// true means skip, so I can check if the url matches
// a view, and if it does then skip which will leave
// it to the view handler next
return false
},
})
app.Get("/v/:name/", func (c *fiber.Ctx) error {
return c.Render(c.Params("name"), fiber.Map{
"Title": "Hello, World!",
})
})
app.Get("/api/stream", GetApiStream)
app.Get("/api/logout", GetApiLogout)
app.Get("/api/stream/:id", GetApiStreamId)
@ -120,11 +138,6 @@ func Setup(app *fiber.App) {
app.Post("/api/link", PostApiLink)
app.Post("/api/register", PostApiRegister)
app.Get("/test/:name/", func (c *fiber.Ctx) error {
return c.Render(c.Params("name"), fiber.Map{
"Title": "Hello, World!",
})
})
}