|
|
|
@ -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!", |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|