Files
nixcn-cms/utils/response.go
Asai Neko 6a9c013799
All checks were successful
Build Backend (NixCN CMS) TeamCity build finished
Build Frontend (NixCN CMS) TeamCity build finished
Use utils.HttpResponse/Abort to replace c.JSON/Abort
Signed-off-by: Asai Neko <sugar@sne.moe>
2026-01-06 12:49:55 +08:00

31 lines
641 B
Go

package utils
import "github.com/gin-gonic/gin"
type RespStatus struct {
Code int `json:"code"`
ErrorId string `json:"error_id"`
Status string `json:"status"`
Data any `json:"data"`
}
func HttpResponse(c *gin.Context, code int, errorId string, status string, data ...any) {
var resp = RespStatus{
Code: code,
ErrorId: errorId,
Status: status,
Data: data,
}
c.JSON(code, resp)
}
func HttpAbort(c *gin.Context, code int, errorId string, status string, data ...any) {
var resp = RespStatus{
Code: code,
ErrorId: errorId,
Status: status,
Data: data,
}
c.AbortWithStatusJSON(code, resp)
}