Documentation ¶
Index ¶
- Variables
- func ContextLogger(ctx context.Context) *logrus.Entry
- func GetCause(err error) (error, bool)
- func NewEventContext(ctx context.Context, event *Event) context.Context
- func RequestIP(r *http.Request, trustForwardedFor bool) string
- func RequestLogger(r *http.Request) *logrus.Entry
- func SetRequestError(r *http.Request, err error)
- func SetRequestField(r *http.Request, key string, value interface{})
- func UnwrapAll(err error) error
- type Event
- type HTTPMiddleware
Constants ¶
This section is empty.
Variables ¶
View Source
var ( FieldDuration = "duration" FieldErrorCause = "errorCause" FieldErrorStack = "errorStack" FieldHTTPMethod = "httpMethod" FieldHTTPRemoteAddr = "httpRemoteAddr" FieldHTTPRespLen = "httpRespLen" FieldHTTPRespStatus = "httpRespStatus" FieldHTTPSourceIP = "httpSourceIp" FieldHTTPURI = "httpUri" FieldHTTPUserAgent = "httpUserAgent" FieldProtocol = "protocol" FieldRequestID = "requestId" )
Functions ¶
func GetCause ¶
GetCause unwraps the error and returns the original error if it is not the same as the passed error.
func SetRequestError ¶
func SetRequestField ¶
Types ¶
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
func EventFromContext ¶
type HTTPMiddleware ¶
type HTTPMiddleware struct { BuildEvent func(r *http.Request, e *Event) TrustForwardedFor bool RequestIDHeaderKey string RequestLogMessage string EventLogMessage string LogRequest func(e *Event) LogEvent func(e *Event) // contains filtered or unexported fields }
func NewHTTPMiddleware ¶
func NewHTTPMiddleware(next http.Handler, logger *logrus.Entry) *HTTPMiddleware
func (*HTTPMiddleware) ServeHTTP ¶
func (m *HTTPMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.