package shortcuts import ( "dove/utils/urls" "github.com/gofiber/fiber/v2" ) func Redirect(context *fiber.Ctx, routeName string) error { fullPath, exists := urls.GetFullPath(routeName) if !exists { return fiber.ErrNotFound } if isHtmxRequest(context) { context.Set("HX-Redirect", fullPath) return context.SendStatus(fiber.StatusNoContent) } return context.Redirect(fullPath) } func RedirectToPath(context *fiber.Ctx, path string) error { if isHtmxRequest(context) { context.Set("HX-Redirect", path) return context.SendStatus(fiber.StatusNoContent) } return context.Redirect(path) } func RedirectWithStatus(context *fiber.Ctx, routeName string, statusCode int) error { fullPath, exists := urls.GetFullPath(routeName) if !exists { return fiber.ErrNotFound } if isHtmxRequest(context) { context.Set("HX-Redirect", fullPath) return context.SendStatus(fiber.StatusNoContent) } return context.Redirect(fullPath, statusCode) }