Documentation
¶
Overview ¶
Package apilog captures OpenFGA HTTP traffic for the playground's API Logs view. It is transport-level and independent of the TUI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Transport ¶
func Transport(base http.RoundTripper, rec *Recorder, apiURL string) http.RoundTripper
Transport returns an http.RoundTripper that records each attempt into rec. It sits beneath the SDK's auth/retry chain (installed via WithBaseTransport), so it sees the fully-decorated request and the raw response, and re-wraps both body streams so the SDK's own reads are never disturbed.
apiURL is the resolved OpenFGA API endpoint. The SDK also routes out-of-band OAuth token fetches (client_credentials / private_key_jwt) through this same base transport, and those requests carry secrets (client_secret in the request body, access_token in the response body) that must never be captured. Only requests whose host matches apiURL's host are recorded; everything else passes straight through unrecorded. As defense-in-depth for deployments where the token endpoint shares a host with the API (e.g. behind a gateway), captured bodies also go through redactBody, which masks known secret field names regardless of host.
Types ¶
type Entry ¶
type Entry struct {
Time time.Time
Method string
URL string
ReqHeaders http.Header
ReqBody []byte
Status int
StatusText string
RespHeaders http.Header
RespBody []byte
Elapsed time.Duration
RequestID string
ServerQueryDuration string
Err string
Attempt int
}
Entry is one captured HTTP attempt. Bodies are stored capped (see Transport); Err is set only on a transport-level failure, not on an HTTP error status.
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder is a concurrency-safe ring buffer of the most recent entries. Add is called from HTTP goroutines; Snapshot is read from the UI goroutine.
func NewRecorder ¶
NewRecorder returns a Recorder holding at most capacity entries.
func (*Recorder) Len ¶
Len returns how many entries the buffer currently holds (0..capacity), without copying them — cheap enough to call on every render.