Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ResetJSONMarshal ¶
func ResetJSONMarshal(fn JSONMarshaler)
func ResetStdJSONMarshal ¶
func ResetStdJSONMarshal()
Types ¶
type Data ¶
Data contains ContentType and bytes data.
func (Data) WriteContentType ¶
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 ¶
Render (HTML) executes template and writes its result with custom ContentType for response.
func (HTML) WriteContentType ¶
WriteContentType (HTML) writes HTML ContentType.
type HTMLDebug ¶ added in v0.3.1
type HTMLProduction ¶
HTMLProduction contains template reference and its delims.
func (HTMLProduction) Close ¶ added in v0.3.1
func (r HTMLProduction) Close() error
func (HTMLProduction) Instance ¶
func (r HTMLProduction) Instance(name string, data interface{}) Render
Instance (HTMLProduction) returns an HTML instance which it realizes Render interface.
type HTMLRender ¶
type HTMLRender interface { // Instance returns an HTML instance. Instance(string, interface{}) Render Close() error }
HTMLRender interface is to be implemented by HTMLProduction and HTMLDebug.
type JSONMarshaler ¶
customize json.Marshal as you like
type JSONRender ¶
type JSONRender struct {
Data interface{}
}
JSON contains the given interface object.
func (JSONRender) Render ¶
func (r JSONRender) Render(resp *protocol.Response) error
Render (JSON) writes data with custom ContentType.
func (JSONRender) WriteContentType ¶
func (r JSONRender) WriteContentType(resp *protocol.Response)
WriteContentType (JSON) writes JSON ContentType.
type ProtoBuf ¶
type ProtoBuf struct {
Data interface{}
}
ProtoBuf contains the given interface object.
func (ProtoBuf) Render ¶
Render (ProtoBuf) marshals the given interface object and writes data with custom ContentType.
func (ProtoBuf) WriteContentType ¶
WriteContentType (ProtoBuf) writes ProtoBuf ContentType.
type PureJSON ¶
type PureJSON struct {
Data interface{}
}
PureJSON contains the given interface object.
func (PureJSON) WriteContentType ¶
WriteContentType (JSON) writes JSON ContentType.
type Render ¶
type Render interface { // Render writes data with custom ContentType. // Do not panic inside, RequestContext will handle it. Render(resp *protocol.Response) error // WriteContentType writes custom ContentType. WriteContentType(resp *protocol.Response) }
Render interface is to be implemented by JSON, XML, HTML, YAML and so on.
type String ¶
type String struct { Format string Data []interface{} }
String contains the given interface object slice and its format.
func (String) WriteContentType ¶
WriteContentType (String) writes Plain ContentType.