Skip to main content

LocationInstance

Trait LocationInstance 

Source
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§

Source

fn name(&self) -> &str

Get location’s name

Source

fn upstream(&self) -> &str

Get the upstream of location

Source

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.

Source

fn headers(&self) -> Option<&Vec<(HeaderName, HeaderValue, bool)>>

Returns the proxy header to upstream

Source

fn client_body_size_limit(&self) -> usize

Returns the client body size limit

Source

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)
Source

fn on_response(&self)

Called when the response is received from the upstream

Provided Methods§

Source

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.

Source

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".

Implementors§