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§
Required Methods§
Sourcefn new_ctx() -> Self::CTX
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§
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 init_downstream_modules(_modules: &mut HttpModules)
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.
Sourcefn 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 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
].
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>>
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: 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,
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.
Sourcefn 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 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.
Sourcefn 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,
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.