Documentation
¶
Overview ¶
Package audit records full request detail (headers and bodies) for later review, off the request path. It is off unless enabled globally or for a key.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capture ¶
type Capture struct {
// contains filtered or unexported fields
}
Capture collects one request's detail while it runs. All methods are safe on a nil Capture, which is what requests that aren't recorded get.
func (*Capture) Upstream ¶
Upstream tees the provider's response body as it is read; the last attempt's wins.
func (*Capture) UpstreamRequest ¶
UpstreamRequest stores the body sent to the provider; the last attempt's wins.
func (*Capture) Writer ¶
func (c *Capture) Writer(w http.ResponseWriter) http.ResponseWriter
Writer wraps w so what the client receives is recorded too.
type Payload ¶
type Payload struct {
Method string `json:"method,omitempty"`
Query string `json:"query,omitempty"`
RequestHeaders map[string][]string `json:"requestHeaders,omitempty"`
ResponseHeaders map[string][]string `json:"responseHeaders,omitempty"`
UpstreamStatus int `json:"upstreamStatus,omitempty"`
UpstreamResponseHeaders map[string][]string `json:"upstreamResponseHeaders,omitempty"`
Request *Body `json:"request,omitempty"`
UpstreamRequest *Body `json:"upstreamRequest,omitempty"`
UpstreamResponse *Body `json:"upstreamResponse,omitempty"`
Response *Body `json:"response,omitempty"`
}
Payload is the detail stored compressed with each entry.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder decides which requests to capture and writes finished ones in batches.
func (*Recorder) Begin ¶
Begin returns a Capture when this request should be recorded, or nil. keyMode is the key's own setting: "on" or "off" override the global switch.
func (*Recorder) Finish ¶
func (r *Recorder) Finish(c *Capture, ev store.UsageEvent, clientIP string)
Finish queues a finished request; ev carries its outcome.
type Settings ¶
type Settings struct {
// Enabled records every key that doesn't set its own mode.
Enabled bool `json:"enabled"`
// Record is "all", "errors" or "success".
Record string `json:"record"`
// SamplePercent records only this share of matching requests.
SamplePercent int `json:"samplePercent"`
// Models limits recording to these glob patterns; empty means every model.
Models []string `json:"models"`
Request bool `json:"request"`
UpstreamRequest bool `json:"upstreamRequest"`
UpstreamResponse bool `json:"upstreamResponse"`
Response bool `json:"response"`
Headers bool `json:"headers"`
// RedactHeaders are hidden on top of the credentials that always are.
RedactHeaders []string `json:"redactHeaders"`
// MaxBodyKB truncates each body; 0 keeps it whole.
MaxBodyKB int `json:"maxBodyKB"`
RetentionDays int `json:"retentionDays"`
MaxEntries int `json:"maxEntries"`
MaxStorageMB int `json:"maxStorageMB"`
}
func DefaultSettings ¶
func DefaultSettings() Settings