Documentation
¶
Overview ¶
Package relay securely relays model API requests to a trusted upstream gateway.
Index ¶
- type Credentials
- type Option
- func WithClient(client *http.Client) Option
- func WithCredentials(credentials Credentials) Option
- func WithMaxRequestBytes(n int64) Option
- func WithMaxStreamLineBytes(n int) Option
- func WithRequestHeaders(headers ...string) Option
- func WithResponseHeaders(headers ...string) Option
- func WithStreamInterruptedEvent(event []byte) Option
- func WithStreamObserver(newObserver func() StreamObserver) Option
- func WithTimeout(timeout time.Duration) Option
- type Relay
- type RequestInfo
- type Result
- type StreamObserver
- type Target
- type TokenSource
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Credentials ¶
Credentials applies an upstream token to a request.
type Option ¶
type Option func(*Relay)
Option configures a Relay.
func WithClient ¶
WithClient sets the outbound client. Its redirect policy is always replaced.
func WithCredentials ¶
func WithCredentials(credentials Credentials) Option
WithCredentials sets how the upstream token is represented. By default it is sent only as an Authorization bearer token.
func WithMaxRequestBytes ¶
WithMaxRequestBytes sets the request body limit.
func WithMaxStreamLineBytes ¶
WithMaxStreamLineBytes sets the maximum SSE line size.
func WithRequestHeaders ¶
WithRequestHeaders replaces the request header allowlist.
func WithResponseHeaders ¶
WithResponseHeaders replaces the response header allowlist.
func WithStreamInterruptedEvent ¶
WithStreamInterruptedEvent sets bytes appended when a streamed response is incomplete.
func WithStreamObserver ¶
func WithStreamObserver(newObserver func() StreamObserver) Option
WithStreamObserver enables SSE observation and completion validation.
func WithTimeout ¶
WithTimeout sets the timeout for one upstream call.
type Relay ¶
type Relay struct {
// contains filtered or unexported fields
}
Relay forwards validated requests to a models gateway.
type RequestInfo ¶
RequestInfo describes the validated request fields needed by the relay.
type Result ¶
type Result struct {
Status int
Info RequestInfo
}
Result reports the upstream response and validator metadata.
type StreamObserver ¶
StreamObserver inspects SSE data fields and verifies stream completion.
type Target ¶
Target resolves a trusted upstream base URL for a request. Implementations must not return unvalidated user input.
type TokenSource ¶
TokenSource supplies and invalidates upstream credentials.