UpstreamProxy class final

Forwards requests Daravel has no route for to another server, usually the Laravel application being migrated (the strangler fig pattern, Blueprint #29): migrated routes answer from Daravel, the rest from Laravel, behind one address, on one database.

Bodies stream both ways without being buffered. Redirects and compressed bodies pass through as they are. Hop-by-hop headers are dropped, and X-Forwarded-For, -Proto, -Host and -Port tell the upstream who asked: trust Daravel in Laravel's TrustProxies so that $request->ip() and generated URLs stay right.

Constructors

UpstreamProxy(Uri upstream, {bool preserveHost = false, Iterable<String> stripResponseHeaders = const ['x-powered-by'], Duration timeout = const Duration(seconds: 60), HttpClient? client})

Properties

hashCode → int
The hash code for this object.
no setterinherited
preserveHost → bool
Sends the client's Host to the upstream instead of the upstream's.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
stripResponseHeaders → Set<String>
Response headers removed before they reach the client.
final
timeout → Duration
How long the upstream has to start answering (then 504).
final
upstream → Uri
The server requests are forwarded to; its path, if any, prefixes theirs (http://legacy/app + /users → http://legacy/app/users).
final

Methods

close() → void
Closes the connections to the upstream.
forward(Request request) → Future<Response>
Forwards request and streams the answer back: 502 when the upstream cannot be reached, 504 when it does not answer within timeout.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
target(Request request) → Uri
The upstream URL of request.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Constants

hopByHop → const Set<String>
Headers that describe one connection, not the message (RFC 9110 §7.6.1), plus the length the server sets again.