Documentation ¶
Index ¶
- Constants
- func Data(w http.ResponseWriter, status int, v []byte)
- func Error(w http.ResponseWriter, status int, v []byte)
- func HTML(w http.ResponseWriter, status int, name string, binding interface{}, ...)
- func Init(o Options)
- func JSON(w http.ResponseWriter, status int, v interface{})
- func Redirect(w http.ResponseWriter, r *http.Request, status int, location string)
- func Render(o Options)
- func Status(w http.ResponseWriter, status int)
- func Template() *template.Template
- func Text(w http.ResponseWriter, status int, v string)
- func XML(w http.ResponseWriter, status int, v interface{})
- type Delimiter
- type HTMLOptions
- type Options
Constants ¶
View Source
const ( ContentType = "Content-Type" ContentLength = "Content-Length" ContentBinary = "application/octet-stream" ContentText = "text/plain" ContentJSON = "application/json" ContentHTML = "text/html" ContentXHTML = "application/xhtml+xml" ContentXML = "text/xml" )
Variables ¶
This section is empty.
Functions ¶
func Data ¶
func Data(w http.ResponseWriter, status int, v []byte)
func Error ¶
func Error(w http.ResponseWriter, status int, v []byte)
Error writes the given HTTP status to the current ResponseWriter
func HTML ¶
func HTML(w http.ResponseWriter, status int, name string, binding interface{}, htmlOptions ...HTMLOptions)
func Init ¶
func Init(o Options)
Init is a external rendering. An single variadic render.Options struct can be optionally provided to configure HTML rendering. The default directory for templates is "templates" and the default file extension is ".tmpl".
func JSON ¶
func JSON(w http.ResponseWriter, status int, v interface{})
func Status ¶
func Status(w http.ResponseWriter, status int)
func Text ¶
func Text(w http.ResponseWriter, status int, v string)
func XML ¶
func XML(w http.ResponseWriter, status int, v interface{})
Types ¶
type Delimiter ¶
type Delimiter struct { // Left delimiter, defaults to {{ Left string `yaml:"Left"` // Right delimiter, defaults to }} Right string `yaml:"Right"` }
Delimiter represents a set of Left and Right delimiters for HTML template rendering
type HTMLOptions ¶
type HTMLOptions struct { // Layout template name. Overrides Options.Layout. Layout string }
HTMLOptions is a struct for overriding some rendering Options for specific HTML call
type Options ¶
type Options struct { // Directory to load templates. Default is "templates" Directory string `yaml:"Directory"` // Layout template name. Will not render a layout if "". Defaults to "". Layout string `yaml:"Layout"` // Extensions to parse template files from. Defaults to [".tmpl"] Extensions []string `yaml:"Extensions"` // Funcs is a slice of FuncMap to apply to the template upon compilation. This is useful for helper functions. Defaults to []. FuncMap template.FuncMap `yaml:"FuncMap"` // Delimiter sets the action delimiters to the specified strings in the Delimiter struct. Delimiter Delimiter `yaml:"Delimiter"` // Appends the given charset to the Content-Type header. Default is "UTF-8". Charset string `yaml:"Charset"` // Outputs human readable JSON IndentJSON bool `yaml:"IndentJSON"` // Outputs human readable XML IndentXML bool `yaml:"IndentXML"` // Prefixes the JSON output with the given bytes. PrefixJSON []byte `yaml:"PrefixJSON"` // Prefixes the XML output with the given bytes. PrefixXML []byte `yaml:"PrefixXML"` // Allows changing of output to XHTML instead of HTML. Default is "text/html" HTMLContentType string `yaml:"HTMLContentType"` // Initial BufferPool cap BufferPool int `yaml:"BufferPool"` // Set template in debug mode to refresh template. DebugMode bool `yaml:"DebugMode"` }
Options is a struct for specifying configuration options for the render.Init middleware
Click to show internal directories.
Click to hide internal directories.