render

package
v1.13.7 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 IndentedJSON

type IndentedJSON struct {
	Data any
}

IndentedJSON contains the given interface object.

func (IndentedJSON) Render

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

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) Render

func (r JSON) Render(w http.ResponseWriter) 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)
}

Render interface is to be implemented by JSON and so on.

type String

type String struct {
	Format string
	Data   []any
}

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