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