pub trait LocationInstance: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn upstream(&self) -> &str;
fn rewrite(
&self,
header: &mut RequestHeader,
variables: &mut Option<AHashMap<String, String>>,
) -> Result<bool>;
fn headers(&self) -> Option<&Vec<(HeaderName, HeaderValue, bool)>>;
fn client_body_size_limit(&self) -> usize;
fn on_request(&self) -> Result<(u64, i32)>;
fn on_response(&self);
// Provided methods
fn has_rewrite(&self) -> bool { ... }
fn apply_timeouts(&self, _options: &mut PeerOptions) { ... }
}Expand description
Trait for location instance
Required Methods§
Sourcefn rewrite(
&self,
header: &mut RequestHeader,
variables: &mut Option<AHashMap<String, String>>,
) -> Result<bool>
fn rewrite( &self, header: &mut RequestHeader, variables: &mut Option<AHashMap<String, String>>, ) -> Result<bool>
Rewrites the request url. Returns whether the path changed; named
captures of the rewrite pattern are added to variables. An error
when the rule gives something that is no path: the request is then
refused and not sent on with the path it came with.
Sourcefn headers(&self) -> Option<&Vec<(HeaderName, HeaderValue, bool)>>
fn headers(&self) -> Option<&Vec<(HeaderName, HeaderValue, bool)>>
Returns the proxy header to upstream
Sourcefn client_body_size_limit(&self) -> usize
fn client_body_size_limit(&self) -> usize
Returns the client body size limit
Sourcefn on_request(&self) -> Result<(u64, i32)>
fn on_request(&self) -> Result<(u64, i32)>
Called when the request is received from the client
Returns
Result<(u64, i32)> - A tuple containing:
- The new total number of accepted requests (u64)
- The new number of currently processing requests (i32)
Sourcefn on_response(&self)
fn on_response(&self)
Called when the response is received from the upstream
Provided Methods§
Sourcefn has_rewrite(&self) -> bool
fn has_rewrite(&self) -> bool
Whether the location has a rewrite rule at all, so that the uri of
a request is only kept (Features::original_uri) where it may be
replaced.
Sourcefn apply_timeouts(&self, _options: &mut PeerOptions)
fn apply_timeouts(&self, _options: &mut PeerOptions)
Puts the timeouts of the location in place of the upstream’s, on the peer of one of its requests. A location that sets none leaves the peer as it is.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".