Documentation ¶
Index ¶
- Variables
- func GetCause(err error) (error, bool)
- func NewEventContext(ctx context.Context, event *Event) context.Context
- func RequestIP(r *http.Request, trustForwardedFor bool) string
- func UnwrapAll(err error) error
- type CaptureResponseWriter
- func (w *CaptureResponseWriter) Duration() time.Duration
- func (w *CaptureResponseWriter) Flush()
- func (w *CaptureResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (w *CaptureResponseWriter) SetWriteDeadline(t time.Time) error
- func (w *CaptureResponseWriter) Unwrap() http.ResponseWriter
- func (w *CaptureResponseWriter) Write(buf []byte) (int, error)
- func (w *CaptureResponseWriter) WriteDuration() time.Duration
- func (w *CaptureResponseWriter) WriteHeader(statusCode int)
- type Event
- type HTTPMiddleware
Constants ¶
This section is empty.
Variables ¶
View Source
var ( AttrDuration = "duration" AttrError = "error" AttrErrorCause = "errorCause" AttrErrorStack = "errorStack" AttrHTTPMethod = "httpMethod" AttrHTTPRemoteAddr = "httpRemoteAddr" AttrHTTPRespLen = "httpRespLen" AttrHTTPRespStatus = "httpRespStatus" AttrHTTPSourceIP = "httpSourceIp" AttrHTTPURI = "httpUri" AttrHTTPUserAgent = "httpUserAgent" AttrProtocol = "protocol" AttrRequestID = "requestId" )
Functions ¶
Types ¶
type CaptureResponseWriter ¶
type CaptureResponseWriter struct { http.ResponseWriter StatusCode int ResponseLength int64 Start time.Time WriteStart time.Time Hijacked bool HeaderWritten bool }
func NewCaptureResponseWriter ¶
func NewCaptureResponseWriter(w http.ResponseWriter) *CaptureResponseWriter
func (*CaptureResponseWriter) Duration ¶
func (w *CaptureResponseWriter) Duration() time.Duration
func (*CaptureResponseWriter) Flush ¶
func (w *CaptureResponseWriter) Flush()
func (*CaptureResponseWriter) Hijack ¶
func (w *CaptureResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
func (*CaptureResponseWriter) SetWriteDeadline ¶ added in v2.0.3
func (w *CaptureResponseWriter) SetWriteDeadline(t time.Time) error
func (*CaptureResponseWriter) Unwrap ¶ added in v2.0.2
func (w *CaptureResponseWriter) Unwrap() http.ResponseWriter
func (*CaptureResponseWriter) Write ¶
func (w *CaptureResponseWriter) Write(buf []byte) (int, error)
func (*CaptureResponseWriter) WriteDuration ¶
func (w *CaptureResponseWriter) WriteDuration() time.Duration
func (*CaptureResponseWriter) WriteHeader ¶
func (w *CaptureResponseWriter) WriteHeader(statusCode int)
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 *slog.Logger) *HTTPMiddleware
func (*HTTPMiddleware) ServeHTTP ¶
func (m *HTTPMiddleware) ServeHTTP(w http.ResponseWriter, r *http.Request)
Click to show internal directories.
Click to hide internal directories.