// Package response provides the unified API envelope {code,message,data}. package response import ( "net/http" "github.com/gin-gonic/gin" ) // Body is the standard JSON response shape for all HTTP APIs. type Body struct { Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data,omitempty"` } // OK writes a success response with optional data. func OK(c *gin.Context, data interface{}) { c.JSON(http.StatusOK, Body{Code: 0, Message: "success", Data: data}) } // Fail writes a business error with HTTP status and app code. func Fail(c *gin.Context, httpStatus int, code int, message string) { c.JSON(httpStatus, Body{Code: code, Message: message}) }