UpstreamProxy class
Proxy that forwards requests to a target through an intermediary.
Supports optional caching, request/response transforms, streaming, and health checks.
Constructors
- UpstreamProxy(ProxyConfig _config)
- Creates an upstream proxy with the given config.
Properties
- config → ProxyConfig
-
The current proxy configuration.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addHeader(
String key, String value) → void - Adds a header that will be sent with every outgoing request.
-
clearCache(
) → Future< void> - Clears all cached responses (memory and disk).
-
disableCache(
) → void - Disables response caching (updates config).
-
dispose(
) → void - Releases all resources held by the proxy.
-
enableCache(
) → void - Enables response caching (updates config).
-
forward(
ProxyRequest request) → Future< ProxyResponse> -
Forwards
requestto the target through the proxy. -
forwardStream(
ProxyRequest request) → Stream< List< int> > - Forwards a request and returns a streaming response (e.g. for SSE).
-
getCachedResponse(
ProxyRequest request) → ProxyResponse? -
Returns a cached response for
requestif a non-expired entry exists. -
getStats(
) → ProxyStats - Returns a snapshot of accumulated traffic statistics.
-
health(
) → Future< bool> - Pings both the proxy and target URLs to verify connectivity.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeHeader(
String key) → void - Removes a previously added extra header.
-
resetStats(
) → void - Resets all statistics counters to zero.
-
setResponseTransform(
ProxyResponse fn(ProxyResponse)) → void - Sets a transform function applied to responses before returning.
-
setTransform(
ProxyRequest fn(ProxyRequest)) → void - Sets a transform function applied to requests before forwarding.
-
testLatency(
) → Future< Duration> - Measures round-trip latency to the proxy.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited