Documentation
¶
Index ¶
- func BuildChain(handler http.Handler, middlewares ...Middleware) http.Handler
- func NewRegionProxy(region server.Region) (*httputil.ReverseProxy, error)
- func NewRegionProxyWithLimiter(region server.Region, limiter *ratelimit.Limiter) (*httputil.ReverseProxy, error)
- func NewTestProxy(host string) *httputil.ReverseProxy
- func NewTestProxyWithLimiter(host string, limiter *ratelimit.Limiter) *httputil.ReverseProxy
- func PrepareInternalErrorReason(r *http.Request) (*http.Request, func() string)
- func SetInternalErrorReason(r *http.Request, reason string)
- type Middleware
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 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
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
SetInternalErrorReason stashes the rich classification on a request context. Used by the logging middleware to read what the proxy's error handler actually saw.