gateway

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultStringLimit

func DefaultStringLimit() int

DefaultStringLimit returns the default string truncation length for verbose output.

Types

type Proxy

type Proxy struct {
	// contains filtered or unexported fields
}

Proxy is the LLM gateway HTTP handler.

func NewProxy

func NewProxy(engine *keep.Engine, cfg *gwconfig.GatewayConfig, logger *audit.Logger, opts ...ProxyOption) (*Proxy, error)

NewProxy creates an LLM gateway proxy.

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP intercepts /v1/messages requests for policy evaluation. All other paths are reverse-proxied without evaluation.

type ProxyOption

type ProxyOption func(*Proxy)

ProxyOption configures optional Proxy behavior.

func WithDebugLogger

func WithDebugLogger(l *slog.Logger) ProxyOption

WithDebugLogger enables debug logging to the given slog.Logger.

func WithVerboseWriter

func WithVerboseWriter(v *VerboseWriter) ProxyOption

WithVerboseWriter enables verbose packet logging.

type VerboseWriter

type VerboseWriter struct {
	// contains filtered or unexported fields
}

VerboseWriter writes human-readable packet dumps to an io.Writer (typically stderr). WARNING: Verbose output may contain sensitive data (API keys, tokens, PII). Only enable in development/debugging. Never enable in production.

func NewVerboseWriter

func NewVerboseWriter(w io.Writer, stringLimit int) *VerboseWriter

NewVerboseWriter creates a verbose writer. If stringLimit > 0, individual string values in JSON are truncated to that length. Pass 0 for no truncation.

func (*VerboseWriter) RequestAfterPolicy

func (v *VerboseWriter) RequestAfterPolicy(body []byte, rule string)

RequestAfterPolicy logs the request after policy mutations.

func (*VerboseWriter) RequestAllowed

func (v *VerboseWriter) RequestAllowed()

RequestAllowed logs that the request passed policy unchanged.

func (*VerboseWriter) RequestDenied

func (v *VerboseWriter) RequestDenied(rule, message string)

RequestDenied logs that a request was denied by policy.

func (*VerboseWriter) RequestRaw

func (v *VerboseWriter) RequestRaw(body []byte)

RequestRaw logs the inbound request, showing metadata as a header and messages pretty-printed.

func (*VerboseWriter) ResponseAfterPolicy

func (v *VerboseWriter) ResponseAfterPolicy(body []byte, rule string)

ResponseAfterPolicy logs the response after policy mutations.

func (*VerboseWriter) ResponseAllowed

func (v *VerboseWriter) ResponseAllowed()

ResponseAllowed logs that the response passed policy unchanged.

func (*VerboseWriter) ResponseDenied

func (v *VerboseWriter) ResponseDenied(rule, message string)

ResponseDenied logs that a response was denied by policy.

func (*VerboseWriter) ResponseRaw

func (v *VerboseWriter) ResponseRaw(body []byte)

ResponseRaw logs the upstream response, showing metadata as a header and content pretty-printed.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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