fix json encode
This commit is contained in:
parent
b28dbdb8c1
commit
be8b56b897
|
@ -122,6 +122,7 @@ func (ctx *Context) Param(k string) string {
|
||||||
func (ctx *Context) json(res responsePayload) (err error) {
|
func (ctx *Context) json(res responsePayload) (err error) {
|
||||||
ctx.Response().Header().Set("Content-Type", "application/json")
|
ctx.Response().Header().Set("Content-Type", "application/json")
|
||||||
encoder := json.NewEncoder(ctx.Response())
|
encoder := json.NewEncoder(ctx.Response())
|
||||||
|
encoder.SetEscapeHTML(false)
|
||||||
if strings.HasPrefix(ctx.Request().Header.Get("User-Agent"), "curl") {
|
if strings.HasPrefix(ctx.Request().Header.Get("User-Agent"), "curl") {
|
||||||
encoder.SetIndent("", "\t")
|
encoder.SetIndent("", "\t")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue