common

package
v0.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 10 Imported by: 5

Documentation

Index

Constants

View Source
const (
	MaxBodySize = 50_000 // 50 KB (uncompressed)
)
View Source
const Version = "0.0.0"

Variables

This section is empty.

Functions

func GetFullURL added in v0.5.0

func GetFullURL(req *http.Request) string

func ParseContentLength added in v0.5.0

func ParseContentLength(contentLength string) int64

func TransformHeaders added in v0.5.0

func TransformHeaders(header http.Header) [][2]string

func TruncateValidationErrorMessage added in v0.5.0

func TruncateValidationErrorMessage(msg string) string

Types

type Config added in v0.5.0

type Config struct {
	ClientID       string
	Env            string
	AppVersion     string
	RequestLogging *RequestLoggingConfig

	// For testing purposes
	DisableSync bool
}

func NewConfig added in v0.8.0

func NewConfig(clientID string) *Config

type Consumer added in v0.5.0

type Consumer struct {
	Identifier string `json:"identifier"`
	Name       string `json:"name,omitempty"`
	Group      string `json:"group,omitempty"`
}

type PathInfo

type PathInfo struct {
	Method string `json:"method"`
	Path   string `json:"path"`
}

type Request

type Request struct {
	Timestamp float64     `json:"timestamp"`
	Method    string      `json:"method"`
	Path      string      `json:"path,omitempty"`
	URL       string      `json:"url"`
	Headers   [][2]string `json:"headers"`
	Size      int64       `json:"size,omitempty"`
	Consumer  string      `json:"consumer,omitempty"`
	Body      []byte      `json:"body,omitempty"`
}

type RequestLoggingConfig

type RequestLoggingConfig struct {
	Enabled                  bool
	LogQueryParams           bool
	LogRequestHeaders        bool
	LogRequestBody           bool
	LogResponseHeaders       bool
	LogResponseBody          bool
	LogPanic                 bool
	CaptureLogs              bool
	CaptureTraces            bool
	MaskQueryParams          []*regexp.Regexp
	MaskHeaders              []*regexp.Regexp
	MaskBodyFields           []*regexp.Regexp
	MaskRequestBodyCallback  func(request *Request) []byte
	MaskResponseBodyCallback func(request *Request, response *Response) []byte
	ExcludePaths             []*regexp.Regexp
	ExcludeCallback          func(request *Request, response *Response) bool
}

func NewRequestLoggingConfig added in v0.8.0

func NewRequestLoggingConfig() *RequestLoggingConfig

type RequestReader added in v0.6.0

type RequestReader struct {
	Reader io.ReadCloser
	// contains filtered or unexported fields
}

func (*RequestReader) Close added in v0.6.0

func (rr *RequestReader) Close() error

func (*RequestReader) Read added in v0.6.0

func (rr *RequestReader) Read(p []byte) (n int, err error)

func (*RequestReader) Size added in v0.6.0

func (rr *RequestReader) Size() int64

type Response

type Response struct {
	StatusCode   int         `json:"status_code"`
	ResponseTime float64     `json:"response_time"`
	Headers      [][2]string `json:"headers"`
	Size         int64       `json:"size,omitempty"`
	Body         []byte      `json:"body,omitempty"`
}

type ResponseWriter added in v0.6.0

type ResponseWriter struct {
	http.ResponseWriter
	Body                   *bytes.Buffer
	CaptureBody            bool
	IsSupportedContentType func(string) bool
	// contains filtered or unexported fields
}

func (*ResponseWriter) Flush added in v0.6.0

func (w *ResponseWriter) Flush()

func (*ResponseWriter) Hijack added in v0.6.0

func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)

func (*ResponseWriter) Push added in v0.6.0

func (w *ResponseWriter) Push(target string, opts *http.PushOptions) error

func (*ResponseWriter) Size added in v0.6.0

func (w *ResponseWriter) Size() int64

func (*ResponseWriter) Status added in v0.6.0

func (w *ResponseWriter) Status() int

func (*ResponseWriter) Unwrap added in v0.11.0

func (w *ResponseWriter) Unwrap() http.ResponseWriter

func (*ResponseWriter) Write added in v0.6.0

func (w *ResponseWriter) Write(b []byte) (int, error)

func (*ResponseWriter) WriteHeader added in v0.6.0

func (w *ResponseWriter) WriteHeader(statusCode int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL