package
0.0.0-20170616082423-66cff7904715
Repository: https://github.com/simonz05/util.git
Documentation: pkg.go.dev
# Functions
No description provided by the author
CloseBody should be used to close an http.Response.Body.
No description provided by the author
DecodeJSON decodes the JSON in res.Body into dest and then closes res.Body.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
IsGet reports whether r.Method is a GET or HEAD request.
MustGet returns a non-empty GET (or HEAD) parameter param and panics with a special error as caught by a deferred httputil.Recover.
NewRequest wraps http.Request.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PathBase returns a Request's base path, if it went via a PrefixHandler.
PathSuffix returns a Request's suffix path, if it went via a PrefixHandler.
Recover is meant to be used at the top of handlers with "defer" to catch errors from MustGet, etc:
func handler(rw http.ResponseWriter, req *http.Request) { defer httputil.Recover(rw, req) id := req.MustGet("id") ...
RecoverJSON is like Recover but returns with a JSON response.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ServeJSONCodeError sends a JSON error response to rw for the provided error value.
ServeJSONError sends a JSON error response to rw for the provided error value.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
An InvalidMethodError is returned when an HTTP handler is invoked with an unsupported method.
PrefixHandler wraps another Handler and verifies that all requests' Path begin with Prefix.
# Type aliases
An InvalidParameterError represents an invalid HTTP parameter.
A MissingParameterError represents a missing HTTP parameter.
No description provided by the author
No description provided by the author
A ServerError is a generic 500 error.