Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Failure ¶ added in v0.1.4
func Failure(render JSONResponseRender, cause error)
func SetDefaultConvertErrorFunc ¶ added in v0.1.4
func SetDefaultConvertErrorFunc(f ConvertErrorFunc)
func Success ¶
func Success(render JSONResponseRender, message string, data ...interface{})
Types ¶
type ConvertErrorFunc ¶ added in v0.1.4
type FailureResponse ¶ added in v0.1.4
type FailureResponse struct { // 错误码,跟 http-status 一致,并且在 grpc 中可以转换成 grpc-status Code int `json:"code"` // 错误原因,定义为业务判定错误码 Reason string `json:"reason"` // 错误信息,为用户可读的信息,可作为用户提示内容 Message string `json:"message"` Details map[string]interface{} `json:"details,omitempty"` Timestamp time.Time `json:"timestamp"` }
type JSONResponseRender ¶ added in v0.1.4
type JSONResponseRender interface {
JSON(code int, data interface{})
}
Click to show internal directories.
Click to hide internal directories.