Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AbortFailedWithCode ¶
AbortFailedWithCode 设置错误,code 返回值并终止请求
func SetFailedWithCode ¶
SetFailedWithCode 设置错误返回值
Types ¶
type Response ¶
type Response struct {
Code int `json:"code"` // 返回的状态码
Result interface{} `json:"result,omitempty"` // 正常返回时的数据,可以为任意数据结构
Message string `json:"message,omitempty"` // 异常返回时的错误信息
}
func NewResponse ¶
func NewResponse() *Response
NewResponse 构造 http 返回值 SetSuccess 时会自动设置 code 为 200 SetFailed 时不需要设置状态码,SetCode 自定义状态码
func (*Response) SetMessage ¶
func (r *Response) SetMessage(m interface{})
func (*Response) SetMessageWithCode ¶
Click to show internal directories.
Click to hide internal directories.