44 lines
1.4 KiB
Go
44 lines
1.4 KiB
Go
package utils
|
|
|
|
import "github.com/gofiber/fiber/v2"
|
|
|
|
func OK(c *fiber.Ctx, data interface{}) error {
|
|
return c.JSON(fiber.Map{"success": true, "data": data})
|
|
}
|
|
|
|
func Created(c *fiber.Ctx, data interface{}) error {
|
|
return c.Status(fiber.StatusCreated).JSON(fiber.Map{"success": true, "data": data})
|
|
}
|
|
|
|
func List(c *fiber.Ctx, data interface{}, total int64) error {
|
|
return c.JSON(fiber.Map{"success": true, "data": data, "total": total})
|
|
}
|
|
|
|
func Message(c *fiber.Ctx, msg string) error {
|
|
return c.JSON(fiber.Map{"success": true, "message": msg})
|
|
}
|
|
|
|
func BadRequest(c *fiber.Ctx, msg string) error {
|
|
return c.Status(fiber.StatusBadRequest).JSON(fiber.Map{"success": false, "message": msg})
|
|
}
|
|
|
|
func Unauthorized(c *fiber.Ctx, msg string) error {
|
|
return c.Status(fiber.StatusUnauthorized).JSON(fiber.Map{"success": false, "message": msg})
|
|
}
|
|
|
|
func Forbidden(c *fiber.Ctx, msg string) error {
|
|
return c.Status(fiber.StatusForbidden).JSON(fiber.Map{"success": false, "message": msg})
|
|
}
|
|
|
|
func NotFound(c *fiber.Ctx, msg string) error {
|
|
return c.Status(fiber.StatusNotFound).JSON(fiber.Map{"success": false, "message": msg})
|
|
}
|
|
|
|
func Conflict(c *fiber.Ctx, msg string) error {
|
|
return c.Status(fiber.StatusConflict).JSON(fiber.Map{"success": false, "message": msg})
|
|
}
|
|
|
|
func Internal(c *fiber.Ctx, msg string) error {
|
|
return c.Status(fiber.StatusInternalServerError).JSON(fiber.Map{"success": false, "message": msg})
|
|
}
|