← All Go packages

github.com/anulum/director-ai/gateway/internal/proxy

package proxy // import "github.com/anulum/director-ai/gateway/internal/proxy"

Package proxy forwards client requests to an upstream OpenAI- compatible
endpoint. No scoring integration yet — that is Phase 3. The point of this
phase is the Go hop itself: terminating TLS, counting requests, and streaming
server-sent events without buffering.

TYPES

type Client struct {
	// Has unexported fields.
}
    Client is a thin HTTP client that forwards one request to the upstream API.
    It is safe for concurrent use.

func New(upstreamURL string, timeout time.Duration) (*Client, error)
    New builds a Client pointing at “upstreamURL“. “timeout“ is the per-request
    total timeout; set to zero to disable.

func (c *Client) Forward(w http.ResponseWriter, r *http.Request)
    Forward proxies the incoming request to the upstream, copying the status
    code, content-type, and body through. It honours streaming responses by
    flushing as soon as data arrives.

func (c *Client) ForwardAuthHeader(on bool)
    ForwardAuthHeader toggles whether the client forwards the incoming
    “Authorization“ header upstream. Production deployments that replace the
    inbound key with a service account should set this to false and supply their
    own header via Inject.