Documentation
¶
Index ¶
- func DefaultTags(r *http.Request) []interface{}
- func WithCommon(ctx context.Context, h http.Handler, fns ...TagsFunc) http.Handler
- func WithContext(ctx context.Context, h http.Handler) http.Handler
- func WithQueryNormalizer(h http.Handler) http.Handler
- func WithQueryTransformer(h http.Handler, t QueryTransformer) http.HandlerFunc
- func WithQueryTransformerFunc(h http.Handler, keys []string, fn StringTransformerFunc) http.Handler
- func WithRecovery(h http.Handler, opts ...RecoveryFunc) http.Handler
- func WithRequestStats(h http.Handler, fns ...TagsFunc) http.Handler
- func WithResponseTime(h http.Handler, fns ...TagsFunc) http.Handler
- type QueryTransformer
- type Recovery
- type RecoveryFunc
- type ResponseWriter
- type StringTransformerFunc
- type TagsFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultTags ¶
DefaultTags extracts the method and path from the request.
func WithCommon ¶
WithCommon wraps the handler with the commonly used middlewares.
func WithContext ¶
WithContext set the context on the request.
func WithQueryNormalizer ¶
WithQueryNormalizer fixes wrong php query string handling as array
func WithQueryTransformer ¶
func WithQueryTransformer(h http.Handler, t QueryTransformer) http.HandlerFunc
WithQueryTransformer returns an http handler that transforms query parameters using the passed transformer.
func WithQueryTransformerFunc ¶
WithQueryTransformerFunc returns an http handler that transforms query parameters using the passed function.
func WithRecovery ¶
func WithRecovery(h http.Handler, opts ...RecoveryFunc) http.Handler
WithRecovery recovers from panics and log the error.
func WithRequestStats ¶
WithRequestStats collects statistics about the request.
Types ¶
type QueryTransformer ¶
type QueryTransformer struct {
// contains filtered or unexported fields
}
QueryTransformer transforms query parameters with the registered functions.
func (*QueryTransformer) Register ¶
func (t *QueryTransformer) Register(keys []string, fn StringTransformerFunc)
Register registers a function as a transformer for the given set of keys.
type Recovery ¶
type Recovery struct {
// contains filtered or unexported fields
}
Recovery is a middleware that will recover from panics and logs the error.
type RecoveryFunc ¶
type RecoveryFunc func(*Recovery)
RecoveryFunc is used to configure the recovery handler.
func WithoutStack ¶
func WithoutStack() RecoveryFunc
WithoutStack disables the stack trace dump from the recovery log.
type ResponseWriter ¶
type ResponseWriter interface {
http.ResponseWriter
// Status returns the status code of the response or 0 if the response has
// not be written.
Status() int
}
ResponseWriter is a wrapper around http.ResponseWriter that provides extra information about the response.
func NewResponseWriter ¶
func NewResponseWriter(rw http.ResponseWriter) ResponseWriter
NewResponseWriter create a new ResponseWriter.
type StringTransformerFunc ¶
StringTransformerFunc represents a function that transforms a string into another string.