render

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteJSON

func WriteJSON(w http.ResponseWriter, obj any) error

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

func WriteString

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

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

Types

type AsciiJSON

type AsciiJSON struct {
	Data any
}

AsciiJSON contains the given interface object.

func (AsciiJSON) Write

func (r AsciiJSON) Write(w http.ResponseWriter) (err error)

Render (AsciiJSON) marshals the given interface object and writes it with custom ContentType.

func (AsciiJSON) WriteContentType

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

WriteContentType (AsciiJSON) writes JSON ContentType.

type IndentedJSON

type IndentedJSON struct {
	Data any
}

IndentedJSON contains the given interface object.

func (IndentedJSON) Write

Render (IndentedJSON) marshals the given interface object and writes it with custom ContentType.

func (IndentedJSON) WriteContentType

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

WriteContentType (IndentedJSON) writes JSON ContentType.

type JSON

type JSON struct {
	Data any
}

JSON contains the given interface object.

func (JSON) Write

func (r JSON) Write(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 JsonpJSON

type JsonpJSON struct {
	Callback string
	Data     any
}

JsonpJSON contains the given interface object its callback.

func (JsonpJSON) Write

func (r JsonpJSON) Write(w http.ResponseWriter) (err error)

Render (JsonpJSON) marshals the given interface object and writes it and its callback with custom ContentType.

func (JsonpJSON) WriteContentType

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

WriteContentType (JsonpJSON) writes Javascript ContentType.

type PureJSON

type PureJSON struct {
	Data any
}

PureJSON contains the given interface object.

func (PureJSON) Write

func (r PureJSON) Write(w http.ResponseWriter) error

Render (PureJSON) writes custom ContentType and encodes the given interface object.

func (PureJSON) WriteContentType

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

WriteContentType (PureJSON) writes custom ContentType.

type Render

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

Render interface is to be implemented by JSON, XML, HTML, YAML and so on.

type SecureJSON

type SecureJSON struct {
	Prefix string
	Data   any
}

SecureJSON contains the given interface object and its prefix.

func (SecureJSON) Write

func (r SecureJSON) Write(w http.ResponseWriter) error

Render (SecureJSON) marshals the given interface object and writes it with custom ContentType.

func (SecureJSON) WriteContentType

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

WriteContentType (SecureJSON) writes JSON ContentType.

type SecureJSONPrefix

type SecureJSONPrefix string

SecureJSONPrefix is a string which represents SecureJSON prefix.

type Text

type Text struct {
	Format string
	Data   []any
}

String contains the given interface object slice and its format.

func (Text) Write

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

Render (String) writes data with custom ContentType.

func (Text) WriteContentType

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

WriteContentType (String) writes Plain ContentType.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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