mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Fixed typo in godoc
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
0097dfafcd
commit
46a9318172
16
context.go
16
context.go
@ -166,16 +166,20 @@ func (c *Context) JSON(code int, i interface{}) (err error) {
|
|||||||
return
|
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) {
|
func (c *Context) JSONIndent(code int, i interface{}, prefix string, indent string) (err error) {
|
||||||
b, err := json.MarshalIndent(i, prefix, indent)
|
b, err := json.MarshalIndent(i, prefix, indent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
c.json(code, b)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Context) json(code int, b []byte) {
|
||||||
c.response.Header().Set(ContentType, ApplicationJSONCharsetUTF8)
|
c.response.Header().Set(ContentType, ApplicationJSONCharsetUTF8)
|
||||||
c.response.WriteHeader(code)
|
c.response.WriteHeader(code)
|
||||||
c.response.Write(b)
|
c.response.Write(b)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// JSONP sends a JSONP response with status code. It uses `callback` to construct
|
// 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
|
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) {
|
func (c *Context) XMLIndent(code int, i interface{}, prefix string, indent string) (err error) {
|
||||||
b, err := xml.MarshalIndent(i, prefix, indent)
|
b, err := xml.MarshalIndent(i, prefix, indent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
c.xml(code, b)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Context) xml(code int, b []byte) {
|
||||||
c.response.Header().Set(ContentType, ApplicationXMLCharsetUTF8)
|
c.response.Header().Set(ContentType, ApplicationXMLCharsetUTF8)
|
||||||
c.response.WriteHeader(code)
|
c.response.WriteHeader(code)
|
||||||
c.response.Write([]byte(xml.Header))
|
c.response.Write([]byte(xml.Header))
|
||||||
c.response.Write(b)
|
c.response.Write(b)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// File sends a response with the content of the file. If `attachment` is set
|
// File sends a response with the content of the file. If `attachment` is set
|
||||||
|
Loading…
Reference in New Issue
Block a user