qudoco-be/utils/index.utils.go

18 lines
345 B
Go

package utils
import "github.com/gofiber/fiber/v2"
func IsEnabled(key bool) func(c *fiber.Ctx) bool {
if key {
return nil
}
return func(c *fiber.Ctx) bool { return true }
}
func CsrfErrorHandler(c *fiber.Ctx, err error) error {
return c.Status(fiber.StatusForbidden).JSON(fiber.Map{
"error": "CSRF protection: " + err.Error(),
})
}