render

package
v0.12.5 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Render

func Render(w http.ResponseWriter, httpStatus int, r Renderer)

Render writes data with custom http status code

func WriteJSON

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

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

Types

type JSON

type JSON struct {
	Data interface{}
}

JSON contains the given interface object.

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 Renderer

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

	// WriteContentType writes custom ContentType.
	WriteContentType(w http.ResponseWriter)
}

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

Jump to

Keyboard shortcuts

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