proxy

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 38 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildGroup

func BuildGroup(entries []proxylib.Entry) *proxyGroup

BuildGroup compiles entries into an isolated proxy group. The returned group is immutable and safe for concurrent use.

func BypassPool

func BypassPool(ctx context.Context) context.Context

BypassPool disables proxy routing for the request (webhooks etc.).

func Error

func Error(w http.ResponseWriter, code int, msg string)

func GroupFromContext

func GroupFromContext(ctx context.Context) *proxyGroup

GroupFromContext returns the group attached to the context, if any.

func InjectGroup

func InjectGroup(ctx context.Context, g *proxyGroup) context.Context

InjectGroup attaches a proxy group to the context. A nil group leaves the context untouched (global pool / direct fallback apply downstream).

func ParseQuotaCooldown

func ParseQuotaCooldown(h http.Header, def time.Duration, now time.Time) time.Duration

func ParseRetryAfter

func ParseRetryAfter(v string, def time.Duration) time.Duration

func WithProxyUse

func WithProxyUse(ctx context.Context) (context.Context, *proxyUse)

WithProxyUse attaches a holder the transport fills with the masked proxy actually used, so the caller can surface it in a response header.

Types

type PoolTransport

type PoolTransport = poolTransport

PoolTransport is the exported name of the proxy-aware RoundTripper used as the shared client's Transport (kept for tests/introspection).

type Proxy

type Proxy struct {
	Client        *http.Client
	State         *resilience.State
	Router        *router.Router
	Snap          *config.Snapshot
	Policy        *policy.Auth
	Registry      *adapter.Registry
	Telemetry     telemetry.Recorder
	Cache         *cache.TTLResponseCache
	Quota         *quota.Tracked
	Plugins       *plugin.Registry
	ConfigVersion int64
	// contains filtered or unexported fields
}

func New

func New(s *config.Snapshot, st *resilience.State, rt *router.Router) *Proxy

func NewWithClient

func NewWithClient(s *config.Snapshot, st *resilience.State, rt *router.Router, reg *adapter.Registry, client *http.Client) *Proxy

NewWithClient 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.

func NewWithRegistry

func NewWithRegistry(s *config.Snapshot, st *resilience.State, rt *router.Router, reg *adapter.Registry) *Proxy

func (*Proxy) AudioSpeech

func (p *Proxy) AudioSpeech(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)

func (*Proxy) AudioTranscriptions

func (p *Proxy) AudioTranscriptions(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)

func (*Proxy) Chat

func (p *Proxy) Chat(w http.ResponseWriter, r *http.Request, meta protocol.ChatMetadata, body []byte)

func (*Proxy) Embeddings

func (p *Proxy) Embeddings(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)

func (*Proxy) Endpoint

func (p *Proxy) Endpoint(w http.ResponseWriter, r *http.Request, endpoint adapter.Endpoint, meta protocol.EndpointMetadata, body []byte)

func (*Proxy) Error

func (p *Proxy) Error(w http.ResponseWriter, code int, msg string)

func (*Proxy) Images

func (p *Proxy) Images(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)

func (*Proxy) Moderations

func (p *Proxy) Moderations(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)

func (*Proxy) Responses

func (p *Proxy) Responses(w http.ResponseWriter, r *http.Request, meta protocol.EndpointMetadata, body []byte)

Jump to

Keyboard shortcuts

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