Documentation ¶
Index ¶
- Constants
- func Fail(r *ghttp.Request)
- func FailWithCodeAndMsg(r *ghttp.Request, code int, message string)
- func FailWithCodeMsgAndEx(r *ghttp.Request, code int, message string, exception interface{})
- func FailWithEx(r *ghttp.Request, exception interface{})
- func FailWithMsg(r *ghttp.Request, message string)
- func Json(r *ghttp.Request, code int, message string, data ...interface{})
- func JsonExit(r *ghttp.Request, err int, msg string, data ...interface{})
- func Ok(r *ghttp.Request)
- func OkWithData(r *ghttp.Request, data interface{})
- func OkWithDataAndMsg(r *ghttp.Request, message string, data interface{})
- func OkWithMsg(r *ghttp.Request, message string)
- type JsonResponse
Constants ¶
View Source
const ( SUCCESS = 200 // 操作成功 FAIL = 201 // 操作失败 SERVER_ERROR = 500 // 服务器内部错误 BUSINESS_ERROR = 501 // 通用业务异常 )
自定义响应枚举
Variables ¶
This section is empty.
Functions ¶
func FailWithCodeAndMsg ¶
FailWithCodeAndMsg 操作失败(自定义错误码和消息)
func FailWithCodeMsgAndEx ¶
FailWithCodeMsgAndEx 操作失败(自定义错误码、消息、异常信息)
func OkWithDataAndMsg ¶
OkWithDataAndMsg 操作成功(自定义消息和数据)
Types ¶
type JsonResponse ¶
type JsonResponse struct { Code int `json:"code"` // 状态码(200:操作成功,201:操作失败,500:服务器内部错误,501:通用业务异常) Message string `json:"message"` // 提示信息 Data interface{} `json:"data"` // 响应数据 Exception interface{} `json:"exception"` // 异常信息 }
JsonResponse 数据返回通用json数据结构
Click to show internal directories.
Click to hide internal directories.