Browse Source

Fix JSON Header response (#14499)

tags/v1.15.0-dev
6543 GitHub 4 years ago
parent
commit
7a3b7037a7
1 changed files with 1 additions and 1 deletions
  1. +1
    -1
      modules/context/context.go

+ 1
- 1
modules/context/context.go View File

@@ -356,8 +356,8 @@ func (ctx *Context) Error(status int, contents ...string) {


// JSON render content as JSON // JSON render content as JSON
func (ctx *Context) JSON(status int, content interface{}) { func (ctx *Context) JSON(status int, content interface{}) {
ctx.Resp.WriteHeader(status)
ctx.Resp.Header().Set("Content-Type", "application/json;charset=utf8") ctx.Resp.Header().Set("Content-Type", "application/json;charset=utf8")
ctx.Resp.WriteHeader(status)
if err := json.NewEncoder(ctx.Resp).Encode(content); err != nil { if err := json.NewEncoder(ctx.Resp).Encode(content); err != nil {
ctx.ServerError("Render JSON failed", err) ctx.ServerError("Render JSON failed", err)
} }


Loading…
Cancel
Save