Crate http_cache_reqwest
source · [−]Expand description
The reqwest middleware implementation for http-cache.
use reqwest::Client;
use reqwest_middleware::{ClientBuilder, Result};
use http_cache_reqwest::{Cache, CacheMode, CACacheManager, HttpCache};
#[tokio::main]
async fn main() -> Result<()> {
let client = ClientBuilder::new(Client::new())
.with(Cache(HttpCache {
mode: CacheMode::Default,
manager: CACacheManager::default(),
options: None,
}))
.build();
client
.get("https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching")
.send()
.await?;
Ok(())
}Structs
CACacheManager
manager-cacacheImplements CacheManager with cacache as the backend.
Configuration options which control behavior of the cache. Use with CachePolicy::new_options().
Caches requests according to http spec.
A basic generic type that represents an HTTP response
MokaCache
manager-mokaA thread-safe, futures-aware concurrent in-memory cache.
MokaCacheBuilder
manager-mokaBuilds a Cache with various configuration knobs.
MokaManager
manager-mokaImplements CacheManager with moka as the backend.
Enums
Similar to make-fetch-happen cache options.
Passed in when the HttpCache struct is being built.