debug toekn

This commit is contained in:
eson 2023-10-18 11:14:49 +08:00
parent 958624afde
commit a8aeacfd96

View File

@ -170,6 +170,54 @@ func (resp *Response) SetWithDebug(sr *StatusResponse, debug interface{}) *Respo
return resp
}
// WithDebug 设置默认debug参数
func (resp *Response) WithDebug(debug interface{}) *Response {
if resp == nil {
panic("must call the func Set... before")
}
resp.Debug = debug
return resp
}
// WithData 设置默认data参数
func (resp *Response) WithData(data interface{}) *Response {
if resp == nil {
panic("must call the func Set... before")
}
resp.Data = data
return resp
}
// WithMessage 设置默认message参数
func (resp *Response) WithMessage(msg string) *Response {
if resp == nil {
panic("must call the func Set... before")
}
resp.Message = msg
return resp
}
// WithError 设置默认error参数
func (resp *Response) WithError(err error) *Response {
if resp == nil {
panic("must call the func Set... before")
}
resp.Message = err.Error()
return resp
}
// SetStatusWithMessage 设置默认StatusResponse(内部自定义) 非默认msg, 可以带data, data只使用一个参数
func (resp *Response) SetStatusWithMessage(sr *StatusResponse, msg string, dataAndDebug ...interface{}) *Response {
newResp := &Response{