GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Why Go
  • Case Studies
  • Use Cases
  • Security
  • Learn
  • Effective Go
  • Go User Manual
  • Standard library
  • Release Notes
  • API
  • Packages
  • Recorded Talks
  • Meetups
  • Conferences

This view

  • Original page
  • New address

GeezerVison is showing pkg.go.dev — gateway package - github.com/majorcontext/keep/internal/gateway - Go Packages

Details

  • checked Valid go.mod file

    The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.

  • checked Redistributable license

    Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.

  • checked Tagged version

    Modules with tagged versions give importers more predictable builds.

  • unchecked Stable version

    When a project reaches major version v1 it is considered stable.

  • Learn more about best practices

Repository

github.com/majorcontext/keep

Links

  • Open Source Insights Logo Open Source Insights

Documentation ¶

Index ¶

  • func DefaultStringLimit() int
  • type Proxy
    • func NewProxy(engine *keep.Engine, cfg *gwconfig.GatewayConfig, logger *audit.Logger, ...) (*Proxy, error)
    • func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)
  • type ProxyOption
    • func WithDebugLogger(l *slog.Logger) ProxyOption
    • func WithVerboseWriter(v *VerboseWriter) ProxyOption
  • type VerboseWriter
    • func NewVerboseWriter(w io.Writer, stringLimit int) *VerboseWriter
    • func (v *VerboseWriter) RequestAfterPolicy(body []byte, rule string)
    • func (v *VerboseWriter) RequestAllowed()
    • func (v *VerboseWriter) RequestDenied(rule, message string)
    • func (v *VerboseWriter) RequestRaw(body []byte)
    • func (v *VerboseWriter) ResponseAfterPolicy(body []byte, rule string)
    • func (v *VerboseWriter) ResponseAllowed()
    • func (v *VerboseWriter) ResponseDenied(rule, message string)
    • func (v *VerboseWriter) ResponseRaw(body []byte)

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.

Source Files ¶

View all Source files
  • proxy.go
  • verbose.go

Directories ¶

Path Synopsis
config
Click to show internal directories.
Click to hide internal directories.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.