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