Spaces:
Sleeping
Sleeping
| package utils | |
| import ( | |
| "github.com/gofiber/fiber/v2" | |
| ) | |
| type Response struct { | |
| Status string `json:"status"` | |
| Message string `json:"message,omitempty"` | |
| Data interface{} `json:"data,omitempty"` | |
| } | |
| func SuccessResponse(c *fiber.Ctx, data interface{}) error { | |
| return c.JSON(Response{ | |
| Status: "success", | |
| Data: data, | |
| }) | |
| } | |
| func ErrorResponse(c *fiber.Ctx, status int, message string) error { | |
| return c.Status(status).JSON(Response{ | |
| Status: "error", | |
| Message: message, | |
| }) | |
| } | |
| func MessageResponse(c *fiber.Ctx, message string) error { | |
| return c.JSON(Response{ | |
| Status: "success", | |
| Message: message, | |
| }) | |
| } |