use {http::request::*, http::*, kutil::transcoding::*, std::sync::*};
pub type CacheableHook = Arc<Box<dyn Fn(CacheableHookContext) -> bool + Send + Sync>>;
pub type EncodableHook = Arc<Box<dyn Fn(EncodableHookContext) -> bool + Send + Sync>>;
pub type CacheKeyHook<CacheKeyT, RequestBodyT> =
Arc<Box<dyn Fn(CacheKeyHookContext<CacheKeyT, RequestBodyT>) + Send + Sync>>;
#[derive(Clone, Debug)]
pub struct CacheableHookContext<'this> {
pub uri: &'this Uri,
pub headers: &'this HeaderMap,
}
impl<'this> CacheableHookContext<'this> {
pub fn new(uri: &'this Uri, headers: &'this HeaderMap) -> Self {
Self { uri, headers }
}
}
#[derive(Clone, Debug)]
pub struct EncodableHookContext<'this> {
pub encoding: &'this Encoding,
pub uri: &'this Uri,
pub headers: &'this HeaderMap,
}
impl<'this> EncodableHookContext<'this> {
pub fn new(encoding: &'this Encoding, uri: &'this Uri, headers: &'this HeaderMap) -> Self {
Self {
encoding,
uri,
headers,
}
}
}
#[derive(Debug)]
pub struct CacheKeyHookContext<'this, CacheKeyT, RequestBodyT> {
pub cache_key: &'this mut CacheKeyT,
pub request: &'this Request<RequestBodyT>,
}
impl<'this, CacheKeyT, RequestBodyT> CacheKeyHookContext<'this, CacheKeyT, RequestBodyT> {
pub fn new(cache_key: &'this mut CacheKeyT, request: &'this Request<RequestBodyT>) -> Self {
Self { cache_key, request }
}
}