Function warp_reverse_proxy::reverse_proxy_filter
source · pub fn reverse_proxy_filter(
base_path: String,
proxy_address: String
) -> impl Filter<Extract = (Response<Body>,), Error = Rejection> + Clone
Expand description
Reverse proxy filter
Forwards the request to the desired location. It maps one to one, meaning
that a request to https://www.bar.foo/handle/this/path
forwarding to https://www.other.location
will result in a request to https://www.other.location/handle/this/path
.
Arguments
-
base_path
- A string with the initial relative path of the endpoint. For example afoo/
applied for an endpointfoo/bar/
will result on a proxy tobar/
(hence/foo
is removed) -
proxy_address
- Base proxy address to forward request.
Examples
When making a filter with a path /handle/this/path
combined with a filter built
with reverse_proxy_filter("handle".to_string(), "localhost:8080")
will make that request arriving to https://www.bar.foo/handle/this/path
be forwarded to localhost:8080/this/path