You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
805 B
36 lines
805 B
package common
|
|
|
|
import (
|
|
"strings"
|
|
"github.com/gofiber/fiber/v2"
|
|
"github.com/gofiber/fiber/v2/middleware/session"
|
|
)
|
|
|
|
var STORE *session.Store
|
|
|
|
func AddAuthedPage(app *fiber.App, must_admin bool, url string, view string) {
|
|
handler := func(c *fiber.Ctx) error {
|
|
_, err := AuthCheck(c, must_admin)
|
|
if err != nil { return c.Redirect("/") }
|
|
|
|
return c.Render(view, c.AllParams())
|
|
}
|
|
|
|
app.Get(url, handler)
|
|
}
|
|
|
|
func AddPage(app *fiber.App, url string, view string) {
|
|
handler := func(c *fiber.Ctx) error {
|
|
return c.Render(view, c.AllParams())
|
|
}
|
|
|
|
app.Get(url, handler)
|
|
}
|
|
|
|
func Page(path string) (func(c *fiber.Ctx) error) {
|
|
page_id := strings.ReplaceAll(path, "/", "-") + "-page"
|
|
|
|
return func (c *fiber.Ctx) error {
|
|
return c.Render(path, fiber.Map{"PageId": page_id})
|
|
}
|
|
}
|
|
|