Documentation ¶
Index ¶
- func SetJsonSerializeEncoder(encoder extension.Encoder)
- func WriteMsgPack(w http.ResponseWriter, obj interface{}) error
- type AsciiJson
- type Data
- type Delims
- type HTML
- type HTMLDebug
- type HTMLProduction
- type HTMLRender
- type Html
- type IActionResult
- type Image
- type IndentedJson
- type Json
- type Jsonp
- type MsgPack
- type ProtoBuf
- type PureJson
- type Redirect
- type SecureJson
- type Text
- type XML
- type YAML
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetJsonSerializeEncoder ¶ added in v1.6.1
func WriteMsgPack ¶
func WriteMsgPack(w http.ResponseWriter, obj interface{}) error
Types ¶
type AsciiJson ¶
type AsciiJson struct {
Data interface{}
}
AsciiJSON contains the given interface object.
func (AsciiJson) Render ¶
func (r AsciiJson) Render(w http.ResponseWriter) (err error)
使用Ascii JSON 生成仅有 ASCII字符的JSON,非ASCII字符将会被转义 actionresult (AsciiJSON) marshals the given interface object and writes it with custom ContentType.
func (AsciiJson) WriteContentType ¶
func (r AsciiJson) WriteContentType(w http.ResponseWriter)
type Data ¶
Data contains ContentType and bytes data.
func FormFileStream ¶
func (Data) WriteContentType ¶
func (r Data) WriteContentType(w http.ResponseWriter)
WriteContentType (Data) writes custom ContentType.
type Delims ¶
type Delims struct { // Left delimiter, defaults to {{. Left string // Right delimiter, defaults to }}. Right string }
Delims represents a set of Left and Right delimiters for HTML template rendering.
type HTML ¶
HTML contains template reference and its name with given interface object.
func (HTML) Render ¶
func (r HTML) Render(w http.ResponseWriter) error
Render (HTML) executes template and writes its result with custom ContentType for response.
func (HTML) WriteContentType ¶
func (r HTML) WriteContentType(w http.ResponseWriter)
WriteContentType (HTML) writes HTML ContentType.
type HTMLDebug ¶
HTMLDebug contains template delims and pattern and function with file list.
func (HTMLDebug) Instance ¶
func (r HTMLDebug) Instance(name string, data interface{}) IActionResult
Instance (HTMLDebug) returns an HTML instance which it realizes Render interface.
type HTMLProduction ¶
HTMLProduction contains template reference and its delims.
func (HTMLProduction) Instance ¶
func (r HTMLProduction) Instance(name string, data interface{}) IActionResult
Instance (HTMLProduction) returns an HTML instance which it realizes Render interface.
type HTMLRender ¶
type HTMLRender interface { // Instance returns an HTML instance. Instance(string, interface{}) IActionResult }
HTMLRender interface is to be implemented by HTMLProduction and HTMLDebug.
type Html ¶
type Html struct {
Document string
}
func (Html) Render ¶
func (r Html) Render(w http.ResponseWriter) error
Render (HTML) executes template and writes its result with custom ContentType for response.
func (Html) WriteContentType ¶
func (r Html) WriteContentType(w http.ResponseWriter)
WriteContentType (HTML) writes HTML ContentType.
type IActionResult ¶
type IActionResult interface { // actionresult writes data with custom ContentType. Render(http.ResponseWriter) error // WriteContentType writes custom ContentType. WriteContentType(w http.ResponseWriter) }
actionresult interface is to be implemented by JSON, XML, HTML, YAML and so on.
type Image ¶ added in v1.6.2
type Image struct {
Data []byte
}
func (Image) WriteContentType ¶ added in v1.6.2
func (r Image) WriteContentType(w http.ResponseWriter)
WriteContentType (Data) writes custom ContentType.
type IndentedJson ¶
type IndentedJson struct {
Data interface{}
}
func (IndentedJson) Render ¶
func (r IndentedJson) Render(w http.ResponseWriter) error
actionresult (IndentedJSON) marshals the given interface object and writes it with custom ContentType.
func (IndentedJson) WriteContentType ¶
func (r IndentedJson) WriteContentType(w http.ResponseWriter)
type Json ¶
type Json struct {
Data interface{}
}
func (Json) Render ¶
func (d Json) Render(w http.ResponseWriter) (err error)
actionresult (JSON) writes data with custom ContentType.
func (Json) WriteContentType ¶
func (d Json) WriteContentType(w http.ResponseWriter)
type Jsonp ¶
type Jsonp struct { Callback string Data interface{} }
func (Jsonp) Render ¶
func (r Jsonp) Render(w http.ResponseWriter) (err error)
callback(extension) actionresult (Jsonp JSON) marshals the given interface object and writes it and its callback with custom ContentType.
func (Jsonp) WriteContentType ¶
func (r Jsonp) WriteContentType(w http.ResponseWriter)
type MsgPack ¶
type MsgPack struct {
Data interface{}
}
func (MsgPack) WriteContentType ¶
func (r MsgPack) WriteContentType(w http.ResponseWriter)
type ProtoBuf ¶
type ProtoBuf struct {
Data interface{}
}
func (ProtoBuf) WriteContentType ¶
func (r ProtoBuf) WriteContentType(w http.ResponseWriter)
WriteContentType (ProtoBuf) writes ProtoBuf ContentType.
type PureJson ¶
type PureJson struct {
Data interface{}
}
PureJSON contains the given interface object.
func (PureJson) Render ¶
func (r PureJson) Render(w http.ResponseWriter) error
原始字符串,不通过Html编码 actionresult (PureJSON) writes custom ContentType and encodes the given interface object.
func (PureJson) WriteContentType ¶
func (r PureJson) WriteContentType(w http.ResponseWriter)
WriteContentType (PureJSON) writes custom ContentType.
type Redirect ¶
func (Redirect) WriteContentType ¶
func (r Redirect) WriteContentType(http.ResponseWriter)
type SecureJson ¶
type SecureJson struct { Prefix string Data interface{} }
func (SecureJson) Render ¶
func (r SecureJson) Render(w http.ResponseWriter) error
SecureJSON 用来防止json劫持。 如果给定的结构体是数值型,默认预置“while(1)” 到response body actionresult (SecureJSON) marshals the given interface object and writes it with custom ContentType.
func (SecureJson) WriteContentType ¶
func (r SecureJson) WriteContentType(w http.ResponseWriter)
type Text ¶
type Text struct { Format string Data []interface{} }
func (Text) WriteContentType ¶
func (r Text) WriteContentType(w http.ResponseWriter)
type XML ¶
type XML struct {
Data interface{}
}
func (XML) WriteContentType ¶
func (r XML) WriteContentType(w http.ResponseWriter)
type YAML ¶
type YAML struct {
Data interface{}
}
func (YAML) WriteContentType ¶
func (r YAML) WriteContentType(w http.ResponseWriter)