Documentation ¶
Index ¶
- Constants
- func BadRequest(cause error) error
- func Forbidden(cause error) error
- func HTTPError(cause error, status int) error
- func ParseJSON(r io.Reader, v interface{}) error
- func WrapHandlerFunc(f HandlerFunc) http.HandlerFunc
- func WriteJSON(w http.ResponseWriter, obj interface{}) error
- type HandlerFunc
- type M
Constants ¶
View Source
const ( JSONContentType = "application/json; charset=utf-8" OctetStreamContentType = "application/octet-stream" )
content types
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
BadRequest convenience method to create http bad request error.
func WrapHandlerFunc ¶
func WrapHandlerFunc(f HandlerFunc) http.HandlerFunc
WrapHandlerFunc convert HandlerFunc to http.HandlerFunc.
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, obj interface{}) error
WriteJSON response an object in JSON encoding.
Types ¶
type HandlerFunc ¶
type HandlerFunc func(http.ResponseWriter, *http.Request) error
HandlerFunc like http.HandlerFunc, bu it returns an error. If the returned error is httpError type, httpError.status will be responded, otherwise http.StatusInternalServerError responded.
Click to show internal directories.
Click to hide internal directories.