Struct surf_vcr::VcrMiddleware [−][src]
pub struct VcrMiddleware { /* fields omitted */ }
Expand description
Record and playback HTTP sessions.
This middleware must be registered to the client after any other middleware that modifies the HTTP request, or those modifications will not be recorded and replayed.
use surf_vcr::{VcrMiddleware, VcrMode};
let vcr = VcrMiddleware::new(
VcrMode::Replay,
"test-sessions/session-recording.yml"
).await?;
let mut client = surf::Client::new()
.with(some_other_middleware)
.with(vcr);
// And then make your requests:
let req = surf::get("https://example.com")
.header("X-my-header", "stuff");
let resp = client.send(req).await?;
Implementations
pub fn with_modify_request<F>(self, modifier: F) -> Self where
F: Fn(&mut VcrRequest) + Send + Sync + 'static,
pub fn with_modify_request<F>(self, modifier: F) -> Self where
F: Fn(&mut VcrRequest) + Send + Sync + 'static,
Register a modifier function to alter requests before saving to disk.
pub fn with_modify_response<F>(self, modifier: F) -> Self where
F: Fn(&mut VcrResponse) + Send + Sync + 'static,
pub fn with_modify_response<F>(self, modifier: F) -> Self where
F: Fn(&mut VcrResponse) + Send + Sync + 'static,
Register a modifier function to alter responses before saving to disk.
Trait Implementations
Asynchronously handle the request, and return a response.
Auto Trait Implementations
impl !RefUnwindSafe for VcrMiddleware
impl Send for VcrMiddleware
impl Sync for VcrMiddleware
impl Unpin for VcrMiddleware
impl !UnwindSafe for VcrMiddleware
Blanket Implementations
Mutably borrows from an owned value. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
type Output = T
type Output = T
Should always be Self
pub fn vzip(self) -> V
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more