Trait RequestFilter

Source
pub trait RequestFilter: Sized {
    type Conf;
    type CTX;

    // Required method
    fn new_ctx() -> Self::CTX;

    // Provided methods
    fn new(conf: Self::Conf) -> Result<Self, Box<Error>>
       where Self: Sized,
             Self::Conf: TryInto<Self, Error = Box<Error>> { ... }
    fn init_downstream_modules(_modules: &mut HttpModules) { ... }
    fn early_request_filter<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _session: &'life1 mut Session,
        _ctx: &'life2 mut Self::CTX,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<Error>>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn handle<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        session: &'life1 mut Session,
        ctx: &'life2 mut Self::CTX,
    ) -> Pin<Box<dyn Future<Output = Result<bool, Box<Error>>> + Send + 'async_trait>>
       where Self::CTX: Send,
             Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn request_filter<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _session: &'life1 mut Session,
        _ctx: &'life2 mut Self::CTX,
    ) -> Pin<Box<dyn Future<Output = Result<RequestFilterResult, Box<Error>>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn upstream_peer<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _session: &'life1 mut Session,
        _ctx: &'life2 mut Self::CTX,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Box<HttpPeer>>, Box<Error>>> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn logging<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        _session: &'life1 mut Session,
        _e: Option<&'life2 Error>,
        _ctx: &'life3 mut Self::CTX,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: Sync + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
}
Expand description

Trait to be implemented by request filters.

Required Associated Types§

Source

type Conf

Configuration type of this handler.

Source

type CTX

Per-request state of this handler, see [pingora::ProxyHttp::CTX]

Required Methods§

Source

fn new_ctx() -> Self::CTX

Creates a new state object, see [pingora::ProxyHttp::new_ctx]

Unlike Pingora’s method, this one is static. This is to accommodate the virtual hosts scenario: the session isn’t available at this point, so it isn’t yet known which one of the possible host-specific handlers will run.

Provided Methods§

Source

fn new(conf: Self::Conf) -> Result<Self, Box<Error>>
where Self: Sized, Self::Conf: TryInto<Self, Error = Box<Error>>,

Creates a new instance of the handler from its configuration.

Source

fn init_downstream_modules(_modules: &mut HttpModules)

Handler to run during Pingora’s init_downstream_modules phase, see [pingora::ProxyHttp::init_downstream_modules].

Unlike Pingora’s method, this one is static. This is to accomodate the virtual hosts scenario: the session isn’t available at this point, so it isn’t yet known which one of the possible host-specific handlers will run.

Source

fn early_request_filter<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _session: &'life1 mut Session, _ctx: &'life2 mut Self::CTX, ) -> Pin<Box<dyn Future<Output = Result<(), Box<Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Handler to run during Pingora’s early_request_filter phase, see [pingora::ProxyHttp::early_request_filter].

Source

fn handle<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, session: &'life1 mut Session, ctx: &'life2 mut Self::CTX, ) -> Pin<Box<dyn Future<Output = Result<bool, Box<Error>>> + Send + 'async_trait>>
where Self::CTX: Send, Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn request_filter<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _session: &'life1 mut Session, _ctx: &'life2 mut Self::CTX, ) -> Pin<Box<dyn Future<Output = Result<RequestFilterResult, Box<Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Handler to run during Pingora’s request_filter phase, see [pingora::ProxyHttp::request_filter]. This uses a different return type to account for the existence of multiple chained handlers.

Source

fn upstream_peer<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _session: &'life1 mut Session, _ctx: &'life2 mut Self::CTX, ) -> Pin<Box<dyn Future<Output = Result<Option<Box<HttpPeer>>, Box<Error>>> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Handler to run during Pingora’s upstream_peer phase, see [pingora::ProxyHttp::upstream_peer]. Unlike Pingora’s method, here returning a result is optional. If None is returned, other handlers in the chain will be called. If all of them return None, an error will be returned to Pingora.

Source

fn logging<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, _session: &'life1 mut Session, _e: Option<&'life2 Error>, _ctx: &'life3 mut Self::CTX, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Handler to run during Pingora’s logging phase, see [pingora::ProxyHttp::logging].

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§