21 lines
473 B
Go
21 lines
473 B
Go
package resp
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type APIResponse struct {
|
|
Code int `json:"code"`
|
|
Message string `json:"message"`
|
|
Data interface{} `json:"data,omitempty"`
|
|
}
|
|
|
|
func OK(c *gin.Context, data interface{}) {
|
|
c.JSON(http.StatusOK, APIResponse{Code: 0, Message: "ok", Data: data})
|
|
}
|
|
|
|
func Error(c *gin.Context, status int, message string) {
|
|
c.JSON(status, APIResponse{Code: status, Message: message})
|
|
} |