pub trait RequestFilter {
type Conf;
type CTX;
// Required methods
fn new_ctx() -> Self::CTX;
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: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn new(conf: Self::Conf) -> Result<Self, Box<Error>>
where Self: Sized,
Self::Conf: TryInto<Self, Error = Box<Error>> { ... }
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 { ... }
}
Expand description
Trait to be implemented by request filters.
Required Associated Types§
Sourcetype CTX
type CTX
Per-request state of this handler, see pingora_proxy::ProxyHttp::CTX
Required Methods§
Sourcefn new_ctx() -> Self::CTX
fn new_ctx() -> Self::CTX
Creates a new sate object, see pingora_proxy::ProxyHttp::new_ctx
Sourcefn 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: '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: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Handler to run during Pingora’s request_filter
state, see
pingora_proxy::ProxyHttp::request_filter
. This uses a different return type to account
for the existence of multiple request filters.
Provided Methods§
Sourcefn new(conf: Self::Conf) -> Result<Self, Box<Error>>
fn new(conf: Self::Conf) -> Result<Self, Box<Error>>
Creates a new instance of the handler from its configuration.
Sourcefn 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>>
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>>
Handles the current request.
This is essentially identical to the request_filter
method but is supposed to be called
when there is only a single handler. Consequently, its result can be returned directly.
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.