weather/web/util/response/response.go

28 lines
545 B
Go
Raw Normal View History

2025-01-02 22:57:51 +08:00
package response
import "github.com/gofiber/fiber/v2"
type ResponseData struct {
Code ResponseCode `json:"code"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func Ok(c *fiber.Ctx, data interface{}) error {
ret := ResponseData{
Code: Success,
Message: Success.String(),
Data: data,
}
return c.JSON(ret)
}
func Error(c *fiber.Ctx, errCode ResponseCode, data interface{}) error {
ret := ResponseData{
Code: errCode,
Message: errCode.String(),
Data: data,
}
return c.JSON(ret)
}