package response import "github.com/gin-gonic/gin" type Envelope struct { Code string `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` } func OK(c *gin.Context, data interface{}) { c.JSON(200, Envelope{Code: "OK", Message: "success", Data: data}) } func Created(c *gin.Context, data interface{}) { c.JSON(201, Envelope{Code: "CREATED", Message: "created", Data: data}) } func Error(c *gin.Context, status int, code, message string) { c.AbortWithStatusJSON(status, Envelope{Code: code, Message: message}) }