From 46a93181723389148a41a5fc1e7a4a82e1da4094 Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Sat, 7 Nov 2015 20:06:58 -0800 Subject: [PATCH] Fixed typo in godoc Signed-off-by: Vishal Rana --- context.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/context.go b/context.go index 7fca00e5..28d85ed3 100644 --- a/context.go +++ b/context.go @@ -166,16 +166,20 @@ func (c *Context) JSON(code int, i interface{}) (err error) { return } -// JSON sends a JSON response with status code, but it applies prefix and indent to format the output. +// JSONIndent sends a JSON response with status code, but it applies prefix and indent to format the output. func (c *Context) JSONIndent(code int, i interface{}, prefix string, indent string) (err error) { b, err := json.MarshalIndent(i, prefix, indent) if err != nil { return err } + c.json(code, b) + return +} + +func (c *Context) json(code int, b []byte) { 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 @@ -206,17 +210,21 @@ func (c *Context) XML(code int, i interface{}) (err error) { return } -// XML sends an XML response with status code, but it applies prefix and indent to format the output. +// XMLIndent sends an XML response with status code, but it applies prefix and indent to format the output. func (c *Context) XMLIndent(code int, i interface{}, prefix string, indent string) (err error) { b, err := xml.MarshalIndent(i, prefix, indent) if err != nil { return err } + c.xml(code, b) + return +} + +func (c *Context) xml(code int, b []byte) { c.response.Header().Set(ContentType, ApplicationXMLCharsetUTF8) c.response.WriteHeader(code) c.response.Write([]byte(xml.Header)) c.response.Write(b) - return } // File sends a response with the content of the file. If `attachment` is set