render

package
v0.0.0-...-4cd9d19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteJSON

func WriteJSON(w http.ResponseWriter, obj interface{}) error

func WriteString

func WriteString(w http.ResponseWriter, format string, data []interface{}) (err error)

WriteString writes data according to its format and write custom ContentType.

Types

type Delims

type Delims struct {
	// Left delimiter, defaults to {{.
	Left string
	// Right delimiter, defaults to }}.
	Right string
}

type HTML

type HTML struct {
	Template *template.Template
	Name     string
	Data     interface{}
}

func (HTML) Render

func (r HTML) Render(w http.ResponseWriter) error

func (HTML) WriteContentType

func (r HTML) WriteContentType(w http.ResponseWriter)

WriteContentType (HTML) writes HTML ContentType.

type HTMLDebug

type HTMLDebug struct {
	Files   []string
	Glob    string
	Delims  Delims
	FuncMap template.FuncMap
}

type HTMLProduction

type HTMLProduction struct {
	Template *template.Template
	Delims   Delims
}

func (HTMLProduction) Instance

func (r HTMLProduction) Instance(name string, data interface{}) Render

type HTMLRender

type HTMLRender interface {
	// Instance returns an HTML instance.
	Instance(string, interface{}) Render
}

type JSON

type JSON struct {
	Data interface{}
}

func (JSON) Render

func (r JSON) Render(w http.ResponseWriter) (err error)

Render (JSON) writes data with custom ContentType.

func (JSON) WriteContentType

func (r JSON) WriteContentType(w http.ResponseWriter)

WriteContentType (JSON) writes JSON ContentType.

type Redirect

type Redirect struct {
	Code     int
	Request  *http.Request
	Location string
}

Redirect contains the http request reference and redirects status code and location.

func (Redirect) Render

func (r Redirect) Render(w http.ResponseWriter) error

Render (Redirect) redirects the http request to new location and writes redirect response.

func (Redirect) WriteContentType

func (r Redirect) WriteContentType(http.ResponseWriter)

WriteContentType (Redirect) don't write any ContentType.

type Render

type Render interface {
	// Render writes data with custom ContentType.
	Render(http.ResponseWriter) error
	// WriteContentType writes custom ContentType.
	WriteContentType(w http.ResponseWriter)
}

type String

type String struct {
	Format string
	Data   []interface{}
}

String contains the given interface object slice and its format.

func (String) Render

func (r String) Render(w http.ResponseWriter) error

Render (String) writes data with custom ContentType.

func (String) WriteContentType

func (r String) WriteContentType(w http.ResponseWriter)

WriteContentType (String) writes Plain ContentType.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL