We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WithOthers
ErrorDto
BuildFullErrorDto
result
MarshalJSON
The text was updated successfully, but these errors were encountered:
For 3: result.MarshalJSON
result.MarshalJSON
func (r *Result) MarshalJSON() ([]byte, error) { prop := make([]string, 0, 4) // code + message prop = append(prop, fmt.Sprintf(`"code":%d`, r.Code)) prop = append(prop, fmt.Sprintf(`"message":"%s"`, r.Message)) // data if r.Data != nil { data, err := json.Marshal(r.Data) if err != nil { return nil, err } prop = append(prop, fmt.Sprintf(`"data":%s`, data)) } // error if r.Error != nil && gin.Mode() == gin.DebugMode { erro, err := json.Marshal(r.Error) if err != nil { return nil, err } prop = append(prop, fmt.Sprintf(`"error":%s`, erro)) } out := "{" + strings.Join(prop, ",") + "}" return []byte(out), nil } func (r *Result) String() string { j, err := r.MarshalJSON() if err != nil { return "" } return string(j) }
Sorry, something went wrong.
Done.
func (r *Result) JSON(c *gin.Context) { if gin.Mode() != gin.DebugMode { r.Error = nil } c.JSON(int(r.Status), r) } func (r *Result) XML(c *gin.Context) { if gin.Mode() != gin.DebugMode { r.Error = nil } c.XML(int(r.Status), r) }
No branches or pull requests
WithOthers
forErrorDto
and removeBuildFullErrorDto
.result
and addMarshalJSON
to check run mode.The text was updated successfully, but these errors were encountered: