Documentation ¶
Index ¶
- func ApplicationJSON(h http.Handler) http.Handler
- func BuildErrorCatcher(sentryClient *raven.Client) func(h http.Handler) http.Handler
- func CORS(h http.Handler) http.Handler
- func GzipHandler(h http.Handler) http.Handler
- func MakeError(statusCode int, format string, params ...interface{}) error
- func ThrowError(statusCode int, format string, params ...interface{})
- func XRequestID(h http.Handler) http.Handler
- type HttpError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplicationJSON ¶
ApplicationJSON sets the content-type headr to JSON
func BuildErrorCatcher ¶
Middleware that catches panics, and:
- logs them
- optionally reports them to sentry - pass in "" if you don't want this
- sends a 500 response
You can also use ThrowError() to raise an error that this middleware will catch, for example if you want an error to be reported to sentry
func GzipHandler ¶
GzipHandler is used to compress data
func ThrowError ¶
Types ¶
type HttpError ¶
An error that encapsulates an HTTP status code and message. Use ThrowError() to build an HttpError and raise it as a panic
func (HttpError) WriteResponse ¶
func (h HttpError) WriteResponse(w http.ResponseWriter)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.