whjson

package
v0.0.0-...-3f30213 Latest Latest
Warning

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

Go to latest
Published: May 30, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package whjson provides some nice utilities for dealing with JSON-based APIs, such as a good JSON wherr.Handler.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHandler provides a good wherr.Handler. It will return a JSON object
	// like `{"err": "message"}` where message is filled in with
	// errhttp.GetErrorBody. The status code is set with errhttp.GetStatusCode.
	ErrHandler = wherr.HandlerFunc(errHandler)
)

Functions

func Render

func Render(w http.ResponseWriter, r *http.Request, value interface{})

Render will render JSON `value` like `{"resp": <value>}`, falling back to ErrHandler if no error handler was registered and an error is encountered. This is good for making sure your API is always returning usefully namespaced JSON objects that are clearly differentiated from error responses.

Types

This section is empty.

Jump to

Keyboard shortcuts

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