Documentation
¶
Index ¶
- Variables
- func NewHandler(handler http.Handler) http.Handler
- func NewHandlerWith(logger *events.Logger, handler http.Handler) http.Handler
- func NewHandlerWithSanitizer(sanitizer LogSanitizer, logger *events.Logger, handler http.Handler) http.Handler
- func NewTransport(roundTripper http.RoundTripper) http.RoundTripper
- func NewTransportWith(logger *events.Logger, roundTripper http.RoundTripper) http.RoundTripper
- type HeaderSanitizer
- type LogSanitizer
- func (l LogSanitizer) ReqHeaders(h http.Header) http.Header
- func (l LogSanitizer) ResHeaders(h http.Header) http.Header
- func (l LogSanitizer) WithPathSanitizer(sanitizer PathSanitizer) LogSanitizer
- func (l LogSanitizer) WithQuerySanitizer(sanitizer QuerySanitizer) LogSanitizer
- func (l LogSanitizer) WithReqHeaderSanitizer(sanitizer HeaderSanitizer) LogSanitizer
- func (l LogSanitizer) WithResHeaderSanitizer(sanitizer HeaderSanitizer) LogSanitizer
- type PathSanitizer
- type QuerySanitizer
Constants ¶
This section is empty.
Variables ¶
var DefaultLogSanitizer = NewLogSanitizer()
Functions ¶
func NewHandler ¶
NewHandler wraps the HTTP handler and returns a new handler which logs all 4xx and 5xx requests with the default logger. All other requests will only be logged in debug mode. See NewHandlerWithSanitizer for more details.
func NewHandlerWith ¶
NewHandlerWith wraps the HTTP handler and returns a new handler which logs all requests with logger. See NewHandlerWithSanitizer for more details.
func NewHandlerWithSanitizer ¶ added in v2.5.2
func NewHandlerWithSanitizer(sanitizer LogSanitizer, logger *events.Logger, handler http.Handler) http.Handler
NewHandlerWithSanitizer wraps the HTTP handler and returns a new handler which logs all requests with logger. The LogSanitizer is used to sanitize the request and response that is logged. eg, to remove PII.
Panics from handler are intercepted and trigger a 500 response if no response header was sent yet. The panic is not silenced tho and is propagated to the parent handler.
func NewTransport ¶
func NewTransport(roundTripper http.RoundTripper) http.RoundTripper
NewTransport wraps roundTripper and returns a new transport which logs all submitted requests with the default logger.
func NewTransportWith ¶
func NewTransportWith(logger *events.Logger, roundTripper http.RoundTripper) http.RoundTripper
NewTransportWith wraps roundTripper and returns a new transport which logs all submitted requests with logger.
Types ¶
type HeaderSanitizer ¶ added in v2.5.2
HeaderSanitizer is a function that sanitizes a header
var DefaultHeaderSanitizer HeaderSanitizer = func(h http.Header) http.Header {
return h
}
type LogSanitizer ¶ added in v2.5.2
type LogSanitizer struct {
Path PathSanitizer
Query QuerySanitizer
// contains filtered or unexported fields
}
func NewLogSanitizer ¶ added in v2.5.2
func NewLogSanitizer() LogSanitizer
func (LogSanitizer) ReqHeaders ¶ added in v2.5.2
func (l LogSanitizer) ReqHeaders(h http.Header) http.Header
ReqHeaders makes a copy of the request headers and sanitizes the resulting headers
func (LogSanitizer) ResHeaders ¶ added in v2.5.2
func (l LogSanitizer) ResHeaders(h http.Header) http.Header
ResHeaders makes a copy of the response headers and sanitizes the resulting headers
func (LogSanitizer) WithPathSanitizer ¶ added in v2.5.2
func (l LogSanitizer) WithPathSanitizer(sanitizer PathSanitizer) LogSanitizer
func (LogSanitizer) WithQuerySanitizer ¶ added in v2.5.2
func (l LogSanitizer) WithQuerySanitizer(sanitizer QuerySanitizer) LogSanitizer
func (LogSanitizer) WithReqHeaderSanitizer ¶ added in v2.5.2
func (l LogSanitizer) WithReqHeaderSanitizer(sanitizer HeaderSanitizer) LogSanitizer
func (LogSanitizer) WithResHeaderSanitizer ¶ added in v2.5.2
func (l LogSanitizer) WithResHeaderSanitizer(sanitizer HeaderSanitizer) LogSanitizer
type PathSanitizer ¶ added in v2.5.2
PathSanitizer is a function that sanitizes a path
var DefaultPathSanitizer PathSanitizer = func(path string) string {
return path
}
type QuerySanitizer ¶ added in v2.5.2
QuerySanitizer is a function that sanitizes a query
var DefaultQuerySanitizer QuerySanitizer = func(query string) string {
return query
}