fiber.go 686 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package test
  2. import (
  3. "html/template"
  4. "strconv"
  5. "time"
  6. "github.com/brianvoe/gofakeit/v6"
  7. "github.com/gofiber/fiber/v2"
  8. "github.com/gofiber/template/html/v2"
  9. )
  10. func GetFiberTestConfig() fiber.Config {
  11. engine := html.New("./../../templates", ".html")
  12. // nolint:gocritic
  13. engine.AddFunc("now", func() time.Time {
  14. return time.Now()
  15. })
  16. // nolint:gosec
  17. engine.AddFunc("noescape", func(str string) template.HTML {
  18. return template.HTML(str)
  19. })
  20. engine.AddFunc("gridsep", func(i, l int) bool {
  21. i++
  22. return i%3 == 0 && i != l
  23. })
  24. engine.AddFunc("version", func() string {
  25. return strconv.Itoa(gofakeit.Number(1, 1000))
  26. })
  27. return fiber.Config{
  28. Views: engine,
  29. }
  30. }