Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPanic = errors.New("panic")
ErrPanic is used when capturing a panic and wrapping it as an error. This error is never returned directly. You can test if an error is caused by a panic using the errors package:
if errors.Is(err, ErrPanic) { // do something }
Functions ¶
This section is empty.
Types ¶
type StandardMiddleware ¶
type StandardMiddleware func(*bottleneck.Context, bottleneck.Next) error
StandardMiddleware is the standard function signature for middleware using the base context type.
func Compress ¶
func Compress() StandardMiddleware
Compress creates a middleware that compresses the response, if the request accepts it.
Supported encodings are: gzip and deflate.
The weighted preference of accepted encodings is not respected. The first supported encoding in the list of accepted encodings will be applied.
func Limit ¶
func Limit(size int64) StandardMiddleware
Limit creates a middleware that returns an error when a request body is larger than size.
func Logger ¶
func Logger() StandardMiddleware
Logger creates a middleware that logs requests after the handler is called.
If an error occurs the status is set to 500 or the status of a bottleneck.Error respectively. Logger should be added before Recover to log panics.
func Recover ¶
func Recover() StandardMiddleware
Recover creates a middleware that recovers from panics and wraps them as errors.
The resulting error embeds ErrPanic and has the form "panic: {panic value}\n{stacktrace}".