package http import ( "github.com/go-playground/validator/v10" "github.com/gofiber/fiber/v2" ) func notFoundResponse(ctx *fiber.Ctx, err ...error) error { errMsg := "Not found" if len(err) > 0 { errMsg = err[0].Error() } return ctx.Status(fiber.StatusNotFound).JSON( fiber.Map{"error": errMsg}, ) } func invalidRequestBodyResponse(ctx *fiber.Ctx) error { return ctx.Status(fiber.StatusBadRequest).JSON( fiber.Map{"error": "Invalid request body"}, ) } func validationErrorResponse(ctx *fiber.Ctx, err error) error { errs := err.(validator.ValidationErrors) return ctx.Status(fiber.StatusBadRequest).JSON( fiber.Map{"errors": validationErrorFormater(errs)}, ) }