Crate rvcr

source ·
Expand description

Record-and-replay middleware for reqwest http client.

Inspired by https://github.com/vcr/vcr and https://git.sr.ht/~rjframe/surf-vcr Rust client.

§Examples

To record the requests, initialize client like following

        use std::path::PathBuf;
        use reqwest::Client;
        use reqwest_middleware::{ClientBuilder, ClientWithMiddleware};
        use rvcr::{VCRMiddleware, VCRMode};

        let mut bundle = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
        bundle.push("tests/resources/replay.vcr.json");

        let middleware: VCRMiddleware = VCRMiddleware::try_from(bundle.clone())
            .unwrap()
            .with_mode(VCRMode::Record);

        let vcr_client: ClientWithMiddleware = ClientBuilder::new(reqwest::Client::new())
            .with(middleware)
            .build();

To use recorded VCR cassette files, replace .with_mode(VCRMode::Record) with .with_mode(VCRMode::Replay)

Structs§

  • Pluggable VCR middleware for record-and-replay for reqwest items

Enums§

Constants§

Type Aliases§