#[non_exhaustive]pub struct Proxy<U, C>{
pub upstreams: U,
pub client: C,
pub url_path_getter: UrlPartGetter,
pub url_query_getter: UrlPartGetter,
pub host_header_getter: HostHeaderGetter,
pub client_ip_forwarding_enabled: bool,
pub strict_path_normalization_enabled: bool,
}Expand description
Handler that can proxy request to other server.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.upstreams: UUpstreams list.
client: CClient for proxy.
url_path_getter: UrlPartGetterUrl path getter.
url_query_getter: UrlPartGetterUrl query getter.
host_header_getter: HostHeaderGetterHost header getter
client_ip_forwarding_enabled: boolFlag to enable x-forwarded-for header.
strict_path_normalization_enabled: boolFlag to reject ambiguous percent-encoded path characters before proxying.
Implementations§
Source§impl<U> Proxy<U, HyperClient<HttpsConnector<HttpConnector>>>
impl<U> Proxy<U, HyperClient<HttpsConnector<HttpConnector>>>
Sourcepub fn use_hyper_client(upstreams: U) -> Self
Available on crate feature hyper-client only.
pub fn use_hyper_client(upstreams: U) -> Self
hyper-client only.Create a new Proxy using the default Hyper client.
This is a convenient way to create a proxy with standard configuration.
Source§impl<U> Proxy<U, ReqwestClient>
impl<U> Proxy<U, ReqwestClient>
Sourcepub fn use_reqwest_client(upstreams: U) -> Self
Available on crate feature reqwest-client only.
pub fn use_reqwest_client(upstreams: U) -> Self
reqwest-client only.Create a new Proxy using the default Reqwest client.
This is a convenient way to create a proxy with standard configuration.
Source§impl<U> Proxy<U, UnixSockClient>
impl<U> Proxy<U, UnixSockClient>
Sourcepub fn use_unix_sock_tunnel(upstreams: U) -> Self
Available on crate feature unix-sock-client only.
pub fn use_unix_sock_tunnel(upstreams: U) -> Self
unix-sock-client only.Create a new Proxy that tunnels connections to a Unix socket.
Source§impl<U, C> Proxy<U, C>
impl<U, C> Proxy<U, C>
Sourcepub fn with_client_ip_forwarding(upstreams: U, client: C) -> Self
pub fn with_client_ip_forwarding(upstreams: U, client: C) -> Self
Create new Proxy with upstreams list and enable x-forwarded-for header.
Sourcepub fn url_path_getter<G>(self, url_path_getter: G) -> Self
pub fn url_path_getter<G>(self, url_path_getter: G) -> Self
Set url path getter.
Sourcepub fn url_query_getter<G>(self, url_query_getter: G) -> Self
pub fn url_query_getter<G>(self, url_query_getter: G) -> Self
Set url query getter.
Sourcepub fn host_header_getter<G>(self, host_header_getter: G) -> Self
pub fn host_header_getter<G>(self, host_header_getter: G) -> Self
Set host header query getter.
Sourcepub fn strict_path_normalization(self, enable: bool) -> Self
pub fn strict_path_normalization(self, enable: bool) -> Self
Enable or disable strict path normalization.
When enabled, the proxy rejects paths that still contain percent-encoded ., /, \,
or % characters after Salvo routing has extracted the path tail. This is useful when the
proxy is used as a security boundary and the upstream server may perform another decode
pass.
Sourcepub fn upstreams_mut(&mut self) -> &mut U
pub fn upstreams_mut(&mut self) -> &mut U
Get upstreams mutable list.
Sourcepub fn client_mut(&mut self) -> &mut C
pub fn client_mut(&mut self) -> &mut C
Get client mutable reference.
Sourcepub fn client_ip_forwarding(self, enable: bool) -> Self
pub fn client_ip_forwarding(self, enable: bool) -> Self
Enable x-forwarded-for header prepending.
Trait Implementations§
Source§impl<U, C> Handler for Proxy<U, C>
impl<U, C> Handler for Proxy<U, C>
Source§fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
_ctrl: &'life4 mut FlowCtrl,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn handle<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
req: &'life1 mut Request,
depot: &'life2 mut Depot,
res: &'life3 mut Response,
_ctrl: &'life4 mut FlowCtrl,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Source§fn arc(self) -> ArcHandlerwhere
Self: Sized,
fn arc(self) -> ArcHandlerwhere
Self: Sized,
ArcHandler.