Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JsonHandler ¶
func JsonHandler(fn interface{}) func(w http.ResponseWriter, r *http.Request)
JsonHandler converts a function capable of being a handler for JSON APIs into a net/http compatible handler. To serve JSON API requests, a function may take either a struct as arguments (to be converted from JSON passed in the body), an http.Request, both or none, and must return a struct pointer, and an error.
Types ¶
type BadRequestError ¶
type BadRequestError struct {
// contains filtered or unexported fields
}
BadRequestError is the specific error which handlers can return to Murphy to signal that the request was erroneous, and therefore a 400 status should be returned (as opposed to a 500).
func BadRequestErrorf ¶
func BadRequestErrorf(format string, args ...interface{}) *BadRequestError
BadRequestErrorf constructs a BadRequestError in a similar fashion than one would use `fmt.Errorf`.
func (BadRequestError) MarshalJSON ¶
func (e BadRequestError) MarshalJSON() ([]byte, error)
MarshalJSON marshalls a BadRequestError as a JSON object with a single entry `err` which contains the string representation of the error it wraps.
type HttpContext ¶
func NewHttpContext ¶
func NewHttpContext(w http.ResponseWriter, r *http.Request) HttpContext