{"modulePath":"github.com/Rethinger/2papi","version":"v0.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package proxy\n\n## Functions\n\n```go\nfunc BuildGroup(entries []proxylib.Entry) *proxyGroup\n```\nBuildGroup compiles entries into an isolated proxy group. The returned group is immutable and safe for concurrent use.\n\n```go\nfunc BypassPool(ctx context.Context) context.Context\n```\nBypassPool disables proxy routing for the request (webhooks etc.).\n\n```go\nfunc Error(w http.ResponseWriter, code int, msg string)\n```\n\n```go\nfunc GroupFromContext(ctx context.Context) *proxyGroup\n```\nGroupFromContext returns the group attached to the context, if any.\n\n```go\nfunc InjectGroup(ctx context.Context, g *proxyGroup) context.Context\n```\nInjectGroup attaches a proxy group to the context. A nil group leaves the context untouched (global pool / direct fallback apply downstream).\n\n```go\nfunc ParseQuotaCooldown(h http.Header, def time.Duration, now time.Time) time.Duration\n```\n\n```go\nfunc ParseRetryAfter(v string, def time.Duration) time.Duration\n```\n\n```go\nfunc WithProxyUse(ctx context.Context) (context.Context, *proxyUse)\n```\nWithProxyUse attaches a holder the transport fills with the masked proxy actually used, so the caller can surface it in a response header.\n\n## Types\n\n```go\ntype PoolTransport = poolTransport\n```\nPoolTransport is the exported name of the proxy-aware RoundTripper used as the shared client's Transport (kept for tests/introspection).\n\n```go\ntype Proxy struct {\n\tClient        *http.Client\n\tState         *resilience.State\n\tRouter        *router.Router\n\tSnap          *config.Snapshot\n\tPolicy        *policy.Auth\n\tRegistry      *adapter.Registry\n\tTelemetry     telemetry.Recorder\n\tCache         *cache.TTLResponseCache\n\tQuota         *quota.Tracked\n\tPlugins       *plugin.Registry\n\tConfigVersion int64\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc New(s *config.Snapshot, st *resilience.State, rt *router.Router) *Proxy\n```\n\n```go\nfunc NewWithClient(s *config.Snapshot, st *resilience.State, rt *router.Router, reg *adapter.Registry, client *http.Client) *Proxy\n```\nNewWithClient builds a Proxy around a caller-provided shared client. The runtime uses this to keep the SAME client (and its pool transport) across snapshot adoptions — registered adapters hold the client, so replacing it would orphan them and the global pool would never apply.\n\n```go\nfunc NewWithRegistry(s *config.Snapshot, st *resilience.State, rt *router.Router, reg *adapter.Registry) *Proxy\n```\n\n```go\nfunc (p *Proxy) AudioSpeech(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)\n```\n\n```go\nfunc (p *Proxy) AudioTranscriptions(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)\n```\n\n```go\nfunc (p *Proxy) Chat(w http.ResponseWriter, r *http.Request, meta protocol.ChatMetadata, body []byte)\n```\n\n```go\nfunc (p *Proxy) Embeddings(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)\n```\n\n```go\nfunc (p *Proxy) Endpoint(w http.ResponseWriter, r *http.Request, endpoint adapter.Endpoint, meta protocol.EndpointMetadata, body []byte)\n```\n\n```go\nfunc (p *Proxy) Error(w http.ResponseWriter, code int, msg string)\n```\n\n```go\nfunc (p *Proxy) Images(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)\n```\n\n```go\nfunc (p *Proxy) Moderations(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)\n```\n\n```go\nfunc (p *Proxy) Responses(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)\n```\n\n","path":"github.com/Rethinger/2papi/internal/proxy","name":"proxy","synopsis":"","isRedistributable":true}
