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.
Click to show internal directories.
Click to hide internal directories.