pub trait ProxyRouter:
Send
+ Sync
+ 'static {
// Required method
fn route(&self, url: &Url) -> Option<Proxy>;
}Expand description
Chooses the proxy for each request, or none to connect directly.
A router is consulted once per request, with its original URL, before connecting. A redirect
or other follow-up request is routed again for its own URL; retrying protocol negotiation on
the same request is not. A Proxy that a router returns still applies its own schemes and
bypass entries, so a request it doesn’t carry connects directly.
Implemented for:
Proxy, which routes the requests its schemes and bypass entries allow;- functions
Fn(&Url) -> Option<Proxy>; Option<R>, whereNoneroutes nothing;- arrays and
Vecs of routers, which return the first router’s proxy that isn’tNone.
use trillium_client::{Proxy, Url};
let corporate = Proxy::new("http://proxy.corp.example:8080")?;
let router = move |url: &Url| {
url.host_str()?
.ends_with(".corp.example")
.then(|| corporate.clone())
};Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".