proxy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildChain

func BuildChain(handler http.Handler, middlewares ...Middleware) http.Handler

BuildChain wraps the base handler with middlewares applied in order. The first middleware in the slice is the outermost (runs first).

func NewRegionProxy

func NewRegionProxy(region server.Region) (*httputil.ReverseProxy, error)

NewRegionProxy creates an httputil.ReverseProxy that forwards requests to the given SP-API region's endpoint. The proxy is wrapped with the provided middleware chain.

func NewRegionProxyWithLimiter

func NewRegionProxyWithLimiter(region server.Region, limiter *ratelimit.Limiter) (*httputil.ReverseProxy, error)

func NewTestProxy

func NewTestProxy(host string) *httputil.ReverseProxy

NewTestProxy creates a proxy that forwards to the given host using plain HTTP. Only for testing - production always uses HTTPS.

func NewTestProxyWithLimiter

func NewTestProxyWithLimiter(host string, limiter *ratelimit.Limiter) *httputil.ReverseProxy

func PrepareInternalErrorReason added in v0.3.0

func PrepareInternalErrorReason(r *http.Request) (*http.Request, func() string)

PrepareInternalErrorReason returns a request whose context carries a writable string slot for the upstream error reason. The logging middleware calls this BEFORE invoking the proxy so the error handler (deeper in the chain) can record into the same slot. Returns the updated request and a getter that reads the current slot value.

func SetInternalErrorReason added in v0.3.0

func SetInternalErrorReason(r *http.Request, reason string)

SetInternalErrorReason stashes the rich classification on a request context. Used by the logging middleware to read what the proxy's error handler actually saw.

Types

type Middleware

type Middleware func(http.Handler) http.Handler

Middleware wraps an http.Handler, adding behavior before/after the next handler.

Jump to

Keyboard shortcuts

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