Documentation
¶
Overview ¶
Package providerproxy is a record/replay HTTP proxy for the metadata providers Audiobookshelf calls out to.
abs-mcp never talks to Audible, Audnexus or iTunes itself: it asks Audiobookshelf to, and Audiobookshelf (a Node app) makes those calls. That puts them out of reach of anything that hooks Go's http.RoundTripper, so go-vcr and friends cannot see them. The only layer that can is a proxy in front of the container.
Audiobookshelf uses axios, which honours HTTPS_PROXY, so pointing it here plus NODE_TLS_REJECT_UNAUTHORIZED=0 (safe: the container is a throwaway) routes every provider call through this process. In record mode the real providers are called once and the responses are written to cassettes; in replay mode - the default, and what CI uses - they are served from disk and no network is touched.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Drift ¶
type Drift struct {
Key string
StatusWas int
StatusIs int
FieldsAdded []string
FieldsRemoved []string
}
Drift is one recorded interaction whose live response no longer has the shape the cassette captured.
Only the shape is compared, never the values: which book Audible ranks first this week is none of our business, but a field appearing, vanishing or changing type is exactly what breaks decoding. Every client bug this suite has found - the providers wrapper, the bookmarks wrapper, the batch update payload - was a shape change of this kind.
type Mode ¶
type Mode int
Mode selects whether the proxy calls the real providers.
const ( // Replay serves from the cassettes and never reaches the network. A // request with no recording is a loud failure, not an empty response. Replay Mode = iota // Record calls the real provider and writes what comes back. Record // Verify calls the real provider and compares the shape of what comes // back against the cassette, without writing. The recorded response is // still what gets served, so a test outcome never depends on what a // provider happened to return today - drift is reported separately. Verify )
type Options ¶
type Options struct {
// Mode defaults to Replay.
Mode Mode
// CassetteDir holds one JSON file per provider host.
CassetteDir string
// Addr to listen on. Must be reachable from the container, so bind all
// interfaces (e.g. "0.0.0.0:18080").
Addr string
// Logger receives replay misses and record notices; defaults to stderr.
Logger *log.Logger
}
Options configure a Proxy.
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy is a MITM HTTP proxy backed by cassettes.
func New ¶
New starts a proxy and returns it. Close stops it and, in Record mode, flushes the cassettes.
func (*Proxy) Drifts ¶
Drifts returns the shape changes seen so far, in a stable order. Empty in any mode but Verify.