Skip to content
This repository has been archived by the owner on Jul 28, 2020. It is now read-only.

Commit

Permalink
Fixed labstack#360
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <[email protected]>
  • Loading branch information
Vishal Rana authored and vishr committed Feb 10, 2016
1 parent fd5f48a commit 4e57fa0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ func (c *Context) JSON(code int, i interface{}) (err error) {
if err != nil {
return err
}
c.response.Header().Set(ContentType, ApplicationJSONCharsetUTF8)
c.response.WriteHeader(code)
c.response.Write(b)
return
return c.JSONBlob(code, b)
}

// JSONIndent sends a JSON response with status code, but it applies prefix and indent to format the output.
Expand All @@ -171,14 +168,15 @@ func (c *Context) JSONIndent(code int, i interface{}, prefix string, indent stri
if err != nil {
return err
}
c.json(code, b)
return
return c.JSONBlob(code, b)
}

func (c *Context) json(code int, b []byte) {
// JSONBlob sends a JSON blob response with status code.
func (c *Context) JSONBlob(code int, b []byte) (err error) {
c.response.Header().Set(ContentType, ApplicationJSONCharsetUTF8)
c.response.WriteHeader(code)
c.response.Write(b)
return
}

// JSONP sends a JSONP response with status code. It uses `callback` to construct
Expand Down

0 comments on commit 4e57fa0

Please sign in to comment.