Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrorHandlerContextKey ctxKey = 1
ErrorHandlerContextKey is used to store an ErrorHandler in the context.
Functions ¶
func DecodeGet ¶
DecodeGet parses the GET parameters of the request into `ret` using github.com/gorilla/schema.
func DecodeJSON ¶ added in v1.6.0
DecodeJSON parses the request body into `ret` as JSON.
func DecodePost ¶
DecodePost parses the POST parameters of the request into `ret` using github.com/gorilla/schema.
func DoRespond ¶
func DoRespond(w http.ResponseWriter, r *http.Request, hr HttpResponse)
DoRespond executes a HttpResponse and has it write to the ResponseWriter.
Types ¶
type ErrorHandler ¶
type ErrorHandler func(code int, msg string, r *http.Request) HttpResponse
ErrorHandler is a callback type that you can register with ContextWithErrorHandler or WithErrorHandler to have your own callback called to render errors.
type HttpResponse ¶
type HttpResponse interface {
Respond(w http.ResponseWriter, r *http.Request) error
}
HttpResponse is what is to be returned from request handlers. Respond gets executed to write the response to the client.
Click to show internal directories.
Click to hide internal directories.