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

Register a modifier function to alter requests before saving to disk.

Register a modifier function to alter responses before saving to disk.

Trait Implementations

Asynchronously handle the request, and return a response.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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