Documentation ¶
Index ¶
Constants ¶
const ( // ContentBinary header value for binary data. ContentBinary = "application/octet-stream" // ContentJSON header value for JSON data. ContentJSON = "application/json" // ContentJSONP header value for JSONP data. ContentJSONP = "application/javascript" // ContentText header value for Text data. ContentText = "text/plain" // ContentHTML header value for HTML data. ContentHTML = "text/html" // ContentType header constant. ContentType = "Content-Type" // ContentDefaultCharset default character encoding. ContentDefaultCharset = "UTF-8" )
Variables ¶
var ( // ColorGreen is a green color ColorGreen = string([]byte{27, 91, 57, 55, 59, 52, 50, 109}) // ColorWhite is a white color ColorWhite = string([]byte{27, 91, 57, 48, 59, 52, 55, 109}) // ColorYellow is a yellow color ColorYellow = string([]byte{27, 91, 57, 55, 59, 52, 51, 109}) // ColorRed is a red color ColorRed = string([]byte{27, 91, 57, 55, 59, 52, 49, 109}) // ColorBlue is a blue color ColorBlue = string([]byte{27, 91, 57, 55, 59, 52, 52, 109}) // ColorMagenta is a magenta color ColorMagenta = string([]byte{27, 91, 57, 55, 59, 52, 53, 109}) // ColorCyan is a cyan color ColorCyan = string([]byte{27, 91, 57, 55, 59, 52, 54, 109}) // DefaultColor is a default color DefaultColor = string([]byte{27, 91, 48, 109}) )
Functions ¶
func SetHTMLTemplateProvider ¶
func SetHTMLTemplateProvider(provider HTMLTemplateProvider)
SetHTMLTemplateProvider sets the default repository
Types ¶
type HTMLTemplateProvider ¶
HTMLTemplateProvider provides a templates
type HTMLTemplateRenderer ¶
type HTMLTemplateRenderer struct {
// contains filtered or unexported fields
}
HTMLTemplateRenderer renders a templates of repository
func NewHTMLTemplateRenderer ¶
func NewHTMLTemplateRenderer(writer http.ResponseWriter) *HTMLTemplateRenderer
NewHTMLTemplateRenderer create a new HTMLTemplateRenderer
func NewHTMLTemplateRendererWithProvider ¶
func NewHTMLTemplateRendererWithProvider(writer http.ResponseWriter, provider HTMLTemplateProvider) *HTMLTemplateRenderer
NewHTMLTemplateRendererWithProvider create a new HTMLTemplateRenderer for specific provider
type HTMLTemplateRepository ¶
type HTMLTemplateRepository struct { // Directory to load templates. Default is "templates". Directory string // FileExtensions to parse template files from. Defaults to [".tmpl"]. FileExtension string // Compilation to compile the templates Compilation TemplateCompilation // UtilFuncs is a FuncMap to apply to the template upon compilation. This is useful for helper functions. Defaults to []. UtilFuncs template.FuncMap // contains filtered or unexported fields }
HTMLTemplateRepository represents a template repository
type HTTPEncoder ¶
type HTTPEncoder struct {
// contains filtered or unexported fields
}
HTTPEncoder encodes into a different formats
func NewHTTPEncoder ¶
func NewHTTPEncoder(writer http.ResponseWriter) *HTTPEncoder
NewHTTPEncoder creates a new encoder for concrete writer
func (*HTTPEncoder) EncodeData ¶
func (enc *HTTPEncoder) EncodeData(data []byte) error
EncodeData encodes an array of bytes
func (*HTTPEncoder) EncodeJSON ¶
func (enc *HTTPEncoder) EncodeJSON(model Model) error
EncodeJSON encodes a data as json
func (*HTTPEncoder) EncodeJSONP ¶
func (enc *HTTPEncoder) EncodeJSONP(callback string, model Model) error
EncodeJSONP encodes a data as jsonp
func (*HTTPEncoder) EncodeText ¶
func (enc *HTTPEncoder) EncodeText(text string) error
EncodeText encodes a plain text
type HandlerFunc ¶
type HandlerFunc func(w http.ResponseWriter, request *http.Request, next http.HandlerFunc)
HandlerFunc is a func that handle middleware operations
func NewHTTPLogger ¶
func NewHTTPLogger(logger Logger, color bool) HandlerFunc
NewHTTPLogger logs a HTTP requests
func NewHTTPStandardLogger ¶
func NewHTTPStandardLogger() HandlerFunc
NewHTTPStandardLogger prints logs into the standard out
type Logger ¶
type Logger interface {
// Println writes an info message
Println(...interface{})
}
Logger that logs information
type TemplateCompilation ¶
type TemplateCompilation uint8
TemplateCompilation defines the compilcation options
const ( // CompileAlways enables compilation everytime when the templates are used CompileAlways TemplateCompilation = iota // CompileOnce enables compilation only once when the templates are used for first time CompileOnce )