Documentation
¶
Overview ¶
Package loghttp provides an helper middleware to log HTTP requests See https://github.com/bloom42/gobox/log/tree/master/examples/http for a working example
Index ¶
- Constants
- func Handler(logger log.Logger, options ...HandlerOption) func(next http.Handler) http.Handler
- type HandlerOption
- func Duration(durationFieldName string) HandlerOption
- func Host(hostFieldName string) HandlerOption
- func Message(message string) HandlerOption
- func Method(methodFieldName string) HandlerOption
- func RemoteAddress(remoteAddressFieldName string) HandlerOption
- func RequestID(requestIDFieldName string) HandlerOption
- func Scheme(schemeFieldName string) HandlerOption
- func Size(sizeFieldName string) HandlerOption
- func Status(statusFieldName string) HandlerOption
- func URL(urlFieldName string) HandlerOption
- func UserAgent(userAgentFieldName string) HandlerOption
Constants ¶
const RequestIDCtxKey ctxKeyRequestID = 0
RequestIDCtxKey is the key that holds the unique request ID in a request context.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HandlerOption ¶
type HandlerOption func(*httpHandler)
HandlerOption are used to configure a HTTPHandler.
func Duration ¶
func Duration(durationFieldName string) HandlerOption
Duration is used to updated HTTPHandler's duration field name. Set an empty string to disable the field.
func Host ¶
func Host(hostFieldName string) HandlerOption
Host is used to updated HTTPHandler's host field name. Set an empty string to disable the field.
func Message ¶
func Message(message string) HandlerOption
Message is used to updated HTTPHandler's message field name. Set an empty string to disable it.
func Method ¶
func Method(methodFieldName string) HandlerOption
Method is used to updated HTTPHandler's method field name. Set an empty string to disable the field.
func RemoteAddress ¶
func RemoteAddress(remoteAddressFieldName string) HandlerOption
RemoteAddress is used to updated HTTPHandler's remote address field name. Set an empty string to disable the field.
func RequestID ¶
func RequestID(requestIDFieldName string) HandlerOption
RequestID is used to updated HTTPHandler's request ID field name. Set an empty string to disable the field.
func Scheme ¶
func Scheme(schemeFieldName string) HandlerOption
Scheme is used to updated HTTPHandler's scheme field name. Set an empty string to disable the field.
func Size ¶
func Size(sizeFieldName string) HandlerOption
Size is used to updated HTTPHandler's size field name. Set an empty string to disable the field.
func Status ¶
func Status(statusFieldName string) HandlerOption
Status is used to updated HTTPHandler's status field name. Set an empty string to disable the field.
func URL ¶
func URL(urlFieldName string) HandlerOption
URL is used to updated HTTPHandler's url field name. Set an empty string to disable the field.
func UserAgent ¶
func UserAgent(userAgentFieldName string) HandlerOption
UserAgent is used to updated HTTPHandler's user agent field name. Set an empty string to disable the field.