Documentation
¶
Overview ¶
Package render render for net/http
Index ¶
- func AsciiJSON(w http.ResponseWriter, code int, obj interface{})
- func Attachment(w http.ResponseWriter, filename string, data []byte)
- func Data(w http.ResponseWriter, code int, contentType string, data []byte)
- func DataFromReader(w http.ResponseWriter, code int, contentLength int64, contentType string, ...)
- func HTML(w http.ResponseWriter, code int, name string, tpl *template.Template, ...)
- func IndentedJSON(w http.ResponseWriter, code int, obj interface{})
- func JSON(w http.ResponseWriter, code int, obj interface{})
- func JSONP(w http.ResponseWriter, r *http.Request, code int, obj interface{})
- func MsgPack(w http.ResponseWriter, code int, obj interface{})
- func ProtoBuf(w http.ResponseWriter, code int, obj interface{})
- func PureJSON(w http.ResponseWriter, code int, obj interface{})
- func Redirect(w http.ResponseWriter, r *http.Request, code int, location string)
- func Render(w http.ResponseWriter, code int, r render.Render)
- func SecureJSON(w http.ResponseWriter, code int, obj interface{})
- func String(w http.ResponseWriter, code int, format string, values ...interface{})
- func XML(w http.ResponseWriter, code int, obj interface{})
- func YAML(w http.ResponseWriter, code int, obj interface{})
- type H
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsciiJSON ¶
func AsciiJSON(w http.ResponseWriter, code int, obj interface{})
AsciiJSON serializes the given struct as JSON into the response body with unicode to ASCII string. It also sets the Content-Type as "application/json".
func Attachment ¶
func Attachment(w http.ResponseWriter, filename string, data []byte)
Attachment attachment application/octet-stream;charset=utf-8
func Data ¶
func Data(w http.ResponseWriter, code int, contentType string, data []byte)
Data writes some data into the body stream and updates the HTTP code.
func DataFromReader ¶
func DataFromReader(w http.ResponseWriter, code int, contentLength int64, contentType string, reader io.Reader, extraHeaders map[string]string)
DataFromReader writes the specified reader into the body stream and updates the HTTP code.
func HTML ¶
HTML renders the HTTP template specified by its file name. It also updates the HTTP code and sets the Content-Type as "text/html". See http://golang.org/doc/articles/wiki/
func IndentedJSON ¶
func IndentedJSON(w http.ResponseWriter, code int, obj interface{})
IndentedJSON serializes the given struct as pretty JSON (indented + endlines) into the response body. It also sets the Content-Type as "application/json". WARNING: we recommend to use this only for development purposes since printing pretty JSON is more CPU and bandwidth consuming. Use Context.JSON() instead.
func JSON ¶
func JSON(w http.ResponseWriter, code int, obj interface{})
JSON serializes the given struct as JSON into the response body. It also sets the Content-Type as "application/json".
func JSONP ¶
func JSONP(w http.ResponseWriter, r *http.Request, code int, obj interface{})
JSONP serializes the given struct as JSON into the response body. It add padding to response body to request data from a server residing in a different domain than the client. It also sets the Content-Type as "application/javascript".
func MsgPack ¶
func MsgPack(w http.ResponseWriter, code int, obj interface{})
MsgPack serializes the given struct as Msgpack into the response body.
func ProtoBuf ¶
func ProtoBuf(w http.ResponseWriter, code int, obj interface{})
ProtoBuf serializes the given struct as ProtoBuf into the response body.
func PureJSON ¶
func PureJSON(w http.ResponseWriter, code int, obj interface{})
PureJSON serializes the given struct as JSON into the response body. PureJSON, unlike JSON, does not replace special html characters with their unicode entities.
func SecureJSON ¶
func SecureJSON(w http.ResponseWriter, code int, obj interface{})
SecureJSON serializes the given struct as Secure JSON into the response body. Default prepends "while(1)," to response body if the given struct is array values. It also sets the Content-Type as "application/json".
func String ¶
func String(w http.ResponseWriter, code int, format string, values ...interface{})
String writes the given string into the response body.
func XML ¶
func XML(w http.ResponseWriter, code int, obj interface{})
XML serializes the given struct as XML into the response body. It also sets the Content-Type as "application/xml".
func YAML ¶
func YAML(w http.ResponseWriter, code int, obj interface{})
YAML serializes the given struct as YAML into the response body.