Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResponseError ¶
func ResponseError(c *gin.Context, code ResponseCode, err error)
ResponseError 错误时返回
Types ¶
type Response ¶
type Response struct { ErrorCode ResponseCode `json:"errno"` // 错误码 ErrorMsg string `json:"errmsg"` // 错误信息 Data interface{} `json:"data"` // 数据信息 TraceID interface{} `json:"trace_id"` // 日志 traceID Stack interface{} `json:"stack"` // 错误堆栈信息 }
Response 响应结构体
type ResponseCode ¶
type ResponseCode int64
ResponseCode 响应状态码
const ( CodeSuccess ResponseCode = iota // success CodeUndefError // 未知的错误 CodeValidError CodeInternalError // 内部错误 CodeInvalidRequestError ResponseCode = 401 CodeCustomize ResponseCode = 1000 CodeNeedLogin ResponseCode = 1100 + iota // 用户需要登录 CodeInvalidToken // 无效 token CodeLoginElsewhere // 用户在别处登录 GROUPALL_SAVE_FLOWERROR ResponseCode = 2001 )
状态码 1000 以下为通用码,1000 以上为用户自定义码
Click to show internal directories.
Click to hide internal directories.