Struct poem_reverse_proxy::ProxyConfig
source · pub struct ProxyConfig { /* private fields */ }Expand description
A configuration object that allows for fine-grained control over a proxy endpoint.
Implementations§
source§impl ProxyConfig
impl ProxyConfig
§Implementation of Builder Functions
The ProxyConfig struct follows the builder pattern to enable explicit and succinct configuration of the proxy endpoint.
sourcepub fn new<'a>(target: impl Into<String>) -> ProxyConfig
pub fn new<'a>(target: impl Into<String>) -> ProxyConfig
Function that creates a new ProxyConfig for a given target and sets all other parameters to their default values. See the default implementation for more information.
sourcepub fn ws_secure<'a>(&'a mut self) -> &'a mut ProxyConfig
pub fn ws_secure<'a>(&'a mut self) -> &'a mut ProxyConfig
This function sets the endpoint to forward websockets over https instead of http. (This is WSS - WebSocket Secure)
sourcepub fn ws_insecure<'a>(&'a mut self) -> &'a mut ProxyConfig
pub fn ws_insecure<'a>(&'a mut self) -> &'a mut ProxyConfig
This function sets the endpoint to forward websockets over http instead of https. This means any information being sent through the websocket has the potential to be intercepted by malicious actors.
sourcepub fn web_secure<'a>(&'a mut self) -> &'a mut ProxyConfig
pub fn web_secure<'a>(&'a mut self) -> &'a mut ProxyConfig
This function sets the endpoint to forward requests to the target over the https protocol. This is a secure and encrypted communication channel that should be utilized when possible.
sourcepub fn web_insecure<'a>(&'a mut self) -> &'a mut ProxyConfig
pub fn web_insecure<'a>(&'a mut self) -> &'a mut ProxyConfig
This function sets the endpoint to forward requests to the target over the http protocol. This is an insecure and unencrypted communication channel that should be used very carefully.
sourcepub fn enable_nesting<'a>(&'a mut self) -> &'a mut ProxyConfig
pub fn enable_nesting<'a>(&'a mut self) -> &'a mut ProxyConfig
This function sets the waypoint to support nesting.
For example,
if endpoint.target is https://google.com and the proxy is reached
at https://proxy_address/favicon.png, the proxy server will forward
the request to https://google.com/favicon.png.
sourcepub fn disable_nesting<'a>(&'a mut self) -> &'a mut ProxyConfig
pub fn disable_nesting<'a>(&'a mut self) -> &'a mut ProxyConfig
This function sets the waypoint to ignore nesting.
For example,
if endpoint.target is https://google.com and the proxy is reached
at https://proxy_address/favicon.png, the proxy server will forward
the request to https://google.com.
sourcepub fn finish<'a>(&'a mut self) -> ProxyConfig
pub fn finish<'a>(&'a mut self) -> ProxyConfig
Finishes off the building proccess by returning a new ProxyConfig object (not reference) that contains all the settings that were previously specified.
source§impl ProxyConfig
impl ProxyConfig
§Convenience Functions
These functions make it possible to get information from the ProxyConfig struct.
sourcepub fn get_web_request_uri(&self, subpath: Option<String>) -> Result<String, ()>
pub fn get_web_request_uri(&self, subpath: Option<String>) -> Result<String, ()>
Returns the target url of the request, including the proper protocol information and the correct pathing if nesting is enabled
An example output would be
"https://proxy.domain.com"
sourcepub fn get_web_socket_uri(&self) -> Result<String, ()>
pub fn get_web_socket_uri(&self) -> Result<String, ()>
Returns the target url of the websocket, including the proper protocol information.
An example output would be
"wss://websocket.domain.com"
Trait Implementations§
source§impl Clone for ProxyConfig
impl Clone for ProxyConfig
source§fn clone(&self) -> ProxyConfig
fn clone(&self) -> ProxyConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for ProxyConfig
impl Debug for ProxyConfig
source§impl Default for ProxyConfig
impl Default for ProxyConfig
source§fn default() -> Self
fn default() -> Self
Returns the default value for the ProxyConfig, which corresponds to the following:
proxy_target: "http://localhost:3000"
web_secure: None
ws_secure: None
support_nesting: false