render

package
v0.0.0-...-d3b5644 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Data

func Data(w http.ResponseWriter, data []byte, contentType string) error

Data writes data with custom ContentType.

func HTML

func HTML(
	w http.ResponseWriter,
	data any,
	template *template.Template,
	name ...string,
) error

HTML executes template and writes its result with custom ContentType for response.

func JSON

func JSON(w http.ResponseWriter, data any, opts ...JSONOption) (err error)

JSON marshals the given interface object and writes it with custom ContentType.

func MsgPack

func MsgPack(w http.ResponseWriter, data any) error

MsgPack encodes the given interface object and writes data with custom ContentType.

func ProtoBuf

func ProtoBuf(w http.ResponseWriter, data any) error

ProtoBuf marshals the given interface object and writes data with custom ContentType.

func Reader

func Reader(
	w http.ResponseWriter,
	reader io.Reader,
	contentLength int64,
	contentType string,
	headers map[string]string,
) error

Reader writes data with custom ContentType and headers.

func Redirect

func Redirect(
	w http.ResponseWriter,
	r *http.Request,
	location string,
	code int,
) error

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

func TOML

func TOML(w http.ResponseWriter, data any) error

TOML marshals the given interface object and writes data with custom ContentType.

func Text

func Text(w http.ResponseWriter, format string, Data ...any) error

Text writes data with custom ContentType.

func XML

func XML(w http.ResponseWriter, data any) error

XML encodes the given interface object and writes data with custom ContentType.

func YAML

func YAML(w http.ResponseWriter, Data any) error

YAML marshals the given interface object and writes data with custom ContentType.

Types

type JSONOption

type JSONOption func(o *jsonOptions)

func AsciiJSON

func AsciiJSON() JSONOption

func IndentedJSON

func IndentedJSON(prefix, indent string) JSONOption

func JsonpJSON

func JsonpJSON(callback string) JSONOption

func PureJSON

func PureJSON() JSONOption

func SecureJSON

func SecureJSON(prefix string) JSONOption

Jump to

Keyboard shortcuts

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