tower_http_cache_plus/cache/hooks.rs
1use {
2 http::*,
3 std::{sync::*, time::*},
4};
5
6/// Hook to get a response's cache duration.
7pub type CacheDurationHook =
8 Arc<Box<dyn Fn(CacheDurationHookContext) -> Option<Duration> + Send + Sync>>;
9
10//
11// CacheDurationHookContext
12//
13
14/// Context for [CacheDurationHook].
15pub struct CacheDurationHookContext<'this> {
16 /// URI.
17 pub uri: &'this Uri,
18
19 /// Headers.
20 pub headers: &'this HeaderMap,
21}
22
23impl<'this> CacheDurationHookContext<'this> {
24 /// Constructor.
25 pub fn new(uri: &'this Uri, headers: &'this HeaderMap) -> Self {
26 Self { uri, headers }
27 }
28}