18 lines
474 B
Go
18 lines
474 B
Go
package controllers
|
|
|
|
import "github.com/gin-gonic/gin"
|
|
|
|
type APIResponse struct {
|
|
Data interface{} `json:"data"`
|
|
Msg string `json:"msg"`
|
|
Code int `json:"code"`
|
|
}
|
|
|
|
func writeSuccess(c *gin.Context, httpStatus int, msg string, data interface{}) {
|
|
c.JSON(httpStatus, APIResponse{Data: data, Msg: msg, Code: httpStatus})
|
|
}
|
|
|
|
func writeError(c *gin.Context, httpStatus int, msg string) {
|
|
c.JSON(httpStatus, APIResponse{Data: nil, Msg: msg, Code: httpStatus})
|
|
}
|