proxy

package
v1.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package proxy contains reverse-proxy routing and capture middleware.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BodyCaptureMiddleware

func BodyCaptureMiddleware(options BodyCaptureOptions, sink BodyCaptureSink, next http.Handler) http.Handler

func IsSSE

func IsSSE(headers http.Header) bool

func LoggingMiddleware

func LoggingMiddleware(logger *slog.Logger, next http.Handler) http.Handler

func NewHandler

func NewHandler(routes []Route, logger *slog.Logger, next http.Handler) (http.Handler, error)

func NewHandlerWithOptions

func NewHandlerWithOptions(routes []Route, logger *slog.Logger, next http.Handler, options HandlerOptions) (http.Handler, error)

Types

type BodyCaptureOptions

type BodyCaptureOptions struct {
	Enabled     bool
	ParseBodies bool
	MaxBodySize int
}

type BodyCaptureSink

type BodyCaptureSink func(*CapturedExchange)

type CapturedExchange

type CapturedExchange struct {
	// Context carries the request context so downstream consumers (e.g. trace
	// enqueue) can create child spans of the HTTP request span.
	Context               context.Context
	Method                string
	Path                  string
	StatusCode            int
	RequestHeaders        http.Header
	RequestBody           []byte
	RequestBodyTruncated  bool
	ResponseHeaders       http.Header
	ResponseBody          []byte
	ResponseBodyTruncated bool
	Streaming             bool
	StreamChunks          int
	TimeToFirstTokenMS    int64
	TimeToFirstTokenUS    int64
	DurationMS            int64
	GatewayOrgID          string
	GatewayWorkspaceID    string
	GatewayKeyID          string
	GatewayTeam           string
	GatewayRole           string
	CorrelationID         string
}

type HandlerOptions

type HandlerOptions struct {
	Transport http.RoundTripper
}

type Route

type Route struct {
	Prefix   string
	Upstream string
}

func DefaultRoutes

func DefaultRoutes() []Route

type Router

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

func NewRouter

func NewRouter(routes []Route) *Router

func (*Router) Match

func (r *Router) Match(path string) (Route, bool)

type StreamBuffer

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

func (*StreamBuffer) Add

func (b *StreamBuffer) Add(chunk []byte)

Add appends an immutable copy of each chunk so captured streaming traces preserve exact wire ordering without retaining caller-owned buffers.

func (*StreamBuffer) Bytes

func (b *StreamBuffer) Bytes() []byte

func (*StreamBuffer) Count

func (b *StreamBuffer) Count() int

func (*StreamBuffer) Truncated

func (b *StreamBuffer) Truncated() bool

Jump to

Keyboard shortcuts

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