MCPcopy Create free account
hub / github.com/06chaynes/http-cache / call

Method call

http-cache-tower/examples/hyper_basic.rs:46–66  ·  view source on GitHub ↗
(&mut self, _req: Request<Full<Bytes>>)

Source from the content-addressed store, hash-verified

44 }
45
46 fn call(&mut self, _req: Request<Full<Bytes>>) -> Self::Future {
47 let count = self
48 .request_count
49 .fetch_add(1, std::sync::atomic::Ordering::SeqCst);
50
51 Box::pin(async move {
52 // Simulate network delay for first request
53 if count == 0 {
54 tokio::time::sleep(std::time::Duration::from_millis(200)).await;
55 }
56
57 let response_body =
58 format!("Response #{} with caching enabled", count + 1);
59
60 Ok(http::Response::builder()
61 .status(StatusCode::OK)
62 .header("cache-control", "max-age=300, public")
63 .header("content-type", "text/plain")
64 .body(Full::new(Bytes::from(response_body)))?)
65 })
66 }
67}
68
69#[tokio::main]

Callers 1

mainFunction · 0.45

Calls 3

bodyMethod · 0.80
headerMethod · 0.80
statusMethod · 0.80

Tested by

no test coverage detected