initial commit
All checks were successful
Build and publish the docker image / build (push) Successful in 58s
All checks were successful
Build and publish the docker image / build (push) Successful in 58s
Signed-off-by: ngn <ngn@ngn.tf>
This commit is contained in:
25
util/render.go
Normal file
25
util/render.go
Normal file
@ -0,0 +1,25 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"git.ngn.tf/ngn/tren/extract"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func Render(c *fiber.Ctx, template string, data fiber.Map) error {
|
||||
if data == nil {
|
||||
data = make(fiber.Map)
|
||||
}
|
||||
|
||||
data["dictionaries"] = extract.Dicts
|
||||
return c.Render(template, data)
|
||||
}
|
||||
|
||||
func RenderError(c *fiber.Ctx, code int, err... error) error {
|
||||
if code == 500 && len(err) > 0 && err[0] != nil{
|
||||
log.Printf("server error: %s", err[0].Error())
|
||||
}
|
||||
|
||||
return c.Redirect("/")
|
||||
}
|
Reference in New Issue
Block a user