render

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteString added in v0.9.2

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

Types

type HTML

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

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 HTMLRender

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

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 Text added in v0.9.2

type Text struct {
	Format string
	Data   []any
}

func (Text) Render added in v0.9.2

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

func (Text) WriteContentType added in v0.9.2

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

Jump to

Keyboard shortcuts

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