1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-14 17:00:39 +00:00

expose more error code in web module

This commit is contained in:
Ming Deng
2020-11-29 21:16:53 +08:00
parent 4afa9d2d25
commit 8d7f48ea75
7 changed files with 74 additions and 42 deletions

View File

@ -261,15 +261,15 @@ func (output *BeegoOutput) XML(data interface{}, hasIndent bool) error {
}
// ServeFormatted serves YAML, XML or JSON, depending on the value of the Accept header
func (output *BeegoOutput) ServeFormatted(data interface{}, hasIndent bool, hasEncode ...bool) {
func (output *BeegoOutput) ServeFormatted(data interface{}, hasIndent bool, hasEncode ...bool) error {
accept := output.Context.Input.Header("Accept")
switch accept {
case ApplicationYAML:
output.YAML(data)
return output.YAML(data)
case ApplicationXML, TextXML:
output.XML(data, hasIndent)
return output.XML(data, hasIndent)
default:
output.JSON(data, hasIndent, len(hasEncode) > 0 && hasEncode[0])
return output.JSON(data, hasIndent, len(hasEncode) > 0 && hasEncode[0])
}
}