Documentation
¶
Index ¶
- func NewTeeReadCloser(r io.Reader, teeBuffer *bytes.Buffer, cb TeeCallBack) io.ReadCloser
- func NewTeeReadCloserPooled(r io.Reader, pool *BytesBufferPool, cb TeeCallBack) io.ReadCloser
- type BytesBuffer
- type BytesBufferPool
- type HTTPLogger
- type HTTPLoggerOp
- type HTTPSLogAttrsConverter
- func (a HTTPSLogAttrsConverter) AttrsHTTPRequestBodyDrain(r *http.Request) []slog.Attr
- func (a HTTPSLogAttrsConverter) AttrsHTTPRequestExcludeBody(r *http.Request) []slog.Attr
- func (a HTTPSLogAttrsConverter) AttrsHTTPResponseDrainBody(r *http.Response) []slog.Attr
- func (a HTTPSLogAttrsConverter) AttrsHTTPResponseExcludeBody(r *http.Response) []slog.Attr
- func (a HTTPSLogAttrsConverter) GroupAttrsAsHTTPRequest(s []slog.Attr) slog.Attr
- func (a HTTPSLogAttrsConverter) GroupAttrsAsHTTPResponse(s []slog.Attr) slog.Attr
- func (a HTTPSLogAttrsConverter) HTTPRequest(r *http.Request) slog.Attr
- func (a HTTPSLogAttrsConverter) HTTPResponse(r *http.Response) slog.Attr
- func (a HTTPSLogAttrsConverter) HTTPResponseWriter(headers http.Header, statusCode int, body []byte) slog.Attr
- func (a HTTPSLogAttrsConverter) Headers(key string, h http.Header) slog.Attr
- func (a HTTPSLogAttrsConverter) URL(u *url.URL) slog.Attr
- type HeaderMatcher
- type LogPolicy
- func (l LogPolicy) ShouldLogRequestBody(r *http.Request) bool
- func (l LogPolicy) ShouldLogResponseBody(r *http.Response) bool
- func (l LogPolicy) ShouldLogResponseWriterBody(headers http.Header, statusCode int, body []byte) bool
- func (l LogPolicy) ShouldMaskHeader(key string, values []string) bool
- func (l LogPolicy) ShouldOmitHeader(key string, values []string) bool
- type Mode
- type RequestBodyLogPolicy
- type ResponseBodyLogPolicy
- type ResponseWriterBodyLogPolicy
- type ResponseWriterWrapper
- type RoundTripperFunc
- type TeeCallBack
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTeeReadCloser ¶
func NewTeeReadCloser(r io.Reader, teeBuffer *bytes.Buffer, cb TeeCallBack) io.ReadCloser
func NewTeeReadCloserPooled ¶
func NewTeeReadCloserPooled(r io.Reader, pool *BytesBufferPool, cb TeeCallBack) io.ReadCloser
Types ¶
type BytesBuffer ¶
type BytesBuffer interface {
Bytes() []byte
}
type BytesBufferPool ¶
type BytesBufferPool struct {
// contains filtered or unexported fields
}
func NewBytesBufferPool ¶
func NewBytesBufferPool(defaultCap int) *BytesBufferPool
func (*BytesBufferPool) Get ¶
func (b *BytesBufferPool) Get() *bytes.Buffer
func (*BytesBufferPool) Put ¶
func (b *BytesBufferPool) Put(buf *bytes.Buffer)
type HTTPLogger ¶
type HTTPLogger struct {
// contains filtered or unexported fields
}
func NewHTTPLogger ¶
func NewHTTPLogger(ops ...HTTPLoggerOp) *HTTPLogger
func (*HTTPLogger) LoggerRoundTripper ¶
func (il *HTTPLogger) LoggerRoundTripper(next http.RoundTripper) RoundTripperFunc
type HTTPLoggerOp ¶
type HTTPLoggerOp func(*HTTPLogger)
func WithLogInLevel ¶
func WithLogInLevel(lvl slog.Leveler) HTTPLoggerOp
func WithLogPolicy ¶
func WithLogPolicy(lp LogPolicy) HTTPLoggerOp
func WithLogger ¶
func WithLogger(logger *slog.Logger) HTTPLoggerOp
func WithMode ¶
func WithMode(m Mode) HTTPLoggerOp
type HTTPSLogAttrsConverter ¶
type HTTPSLogAttrsConverter struct {
// contains filtered or unexported fields
}
func (HTTPSLogAttrsConverter) AttrsHTTPRequestBodyDrain ¶
func (a HTTPSLogAttrsConverter) AttrsHTTPRequestBodyDrain(r *http.Request) []slog.Attr
func (HTTPSLogAttrsConverter) AttrsHTTPRequestExcludeBody ¶
func (a HTTPSLogAttrsConverter) AttrsHTTPRequestExcludeBody(r *http.Request) []slog.Attr
func (HTTPSLogAttrsConverter) AttrsHTTPResponseDrainBody ¶
func (a HTTPSLogAttrsConverter) AttrsHTTPResponseDrainBody(r *http.Response) []slog.Attr
func (HTTPSLogAttrsConverter) AttrsHTTPResponseExcludeBody ¶
func (a HTTPSLogAttrsConverter) AttrsHTTPResponseExcludeBody(r *http.Response) []slog.Attr
func (HTTPSLogAttrsConverter) GroupAttrsAsHTTPRequest ¶
func (a HTTPSLogAttrsConverter) GroupAttrsAsHTTPRequest(s []slog.Attr) slog.Attr
func (HTTPSLogAttrsConverter) GroupAttrsAsHTTPResponse ¶
func (a HTTPSLogAttrsConverter) GroupAttrsAsHTTPResponse(s []slog.Attr) slog.Attr
func (HTTPSLogAttrsConverter) HTTPRequest ¶
func (a HTTPSLogAttrsConverter) HTTPRequest(r *http.Request) slog.Attr
func (HTTPSLogAttrsConverter) HTTPResponse ¶
func (a HTTPSLogAttrsConverter) HTTPResponse(r *http.Response) slog.Attr
func (HTTPSLogAttrsConverter) HTTPResponseWriter ¶
type HeaderMatcher ¶
type LogPolicy ¶
type LogPolicy struct {
RequestBodyLogPolicy RequestBodyLogPolicy
ResponseBodyLogPolicy ResponseBodyLogPolicy
ResponseWriterBodyLogPolicy ResponseWriterBodyLogPolicy
OmitHeaders HeaderMatcher
MaskedValueHeaders HeaderMatcher
}
func (LogPolicy) ShouldLogRequestBody ¶
func (LogPolicy) ShouldLogResponseBody ¶
func (LogPolicy) ShouldLogResponseWriterBody ¶
func (LogPolicy) ShouldMaskHeader ¶
type RequestBodyLogPolicy ¶
var DefaultRequestBodyLogPolicy RequestBodyLogPolicy = func(r *http.Request) bool { contentType := r.Header.Get("Content-Type") contentEncoding := r.Header.Get("Content-Encoding") return len(contentEncoding) == 0 && (strings.Contains(contentType, "application/json") || strings.Contains(contentType, "text/html")) }
type ResponseBodyLogPolicy ¶
type ResponseWriterWrapper ¶
type ResponseWriterWrapper interface {
http.ResponseWriter
Header() http.Header
Buffer() *bytes.Buffer
Status() int
BytesWritten() int
}
func NewResponseWriterWrapper ¶
func NewResponseWriterWrapper(w http.ResponseWriter) ResponseWriterWrapper
type RoundTripperFunc ¶
RoundTripperFunc is an http.RoundTripper signature alias.
type TeeCallBack ¶
Click to show internal directories.
Click to hide internal directories.