diff --git a/api/controllers.go b/api/controllers.go index 0fcf5f9..837522f 100644 --- a/api/controllers.go +++ b/api/controllers.go @@ -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!", - }) - }) } diff --git a/main.go b/main.go index 06ff061..9eb52a8 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "log" "os" - "time" "os/signal" "syscall" "github.com/gofiber/fiber/v2" @@ -25,6 +24,8 @@ func main() { app := fiber.New(fiber.Config{ Views: engine, ViewsLayout: "layouts/main", + CaseSensitive: true, + StrictRouting: true, }) app.Use(logger.New()) @@ -33,11 +34,6 @@ func main() { api.Setup(app) data.Setup("sqlite3", "db.sqlite3") - app.Static("/", "./public", fiber.Static{ - Compress: true, - CacheDuration: 1 * time.Nanosecond, - }) - // this sets up graceful shutdown go func() { if err := app.Listen(":5001"); err != nil { diff --git a/views/index.html b/views/test.html similarity index 100% rename from views/index.html rename to views/test.html