ReqVCR.Recorder (ReqVCR v0.1.0)
View SourceA module to record and replay HTTP requests and responses.
The tape files are stored in the <priv_dir>/vcr_tapes
directory.
Once a tape is recorded, it will be replayed for subsequent requests.
Each tape file is a JSON file containing the request and response data. The filename is generated from the request method, URL, and a checksum of the URL + query parameters.
Headers are also sanitized to remove sensitive information before being stored in the tape.
The header keys sanitized are ["authorization"]
at the moment.
The ReqVCR.Recorder.attach/2
function can be used to attach the VCR to a request and response pipeline.
Examples
iex> [url: "https://example.com"] |> Req.new() |> ReqVCR.Recorder.attach()
iex> [url: "https://example.com", allow_overwrite: true] |> Req.new() |> ReqVCR.Recorder.attach()
iex> [url: "https://example.com", ignore_status: ["404"]] |> Req.new() |> ReqVCR.Recorder.attach()
Options
:allow_overwrite
- allow overwriting existing tapes and thus bypasses replays (default:false
):ignore_status
- a list of status codes to ignore when recording tapes (default:401, 404, 500, 502, 503
):skip_recording
- skip recording the response to a tape (default:false
):tape_name
- a custom name for the tape file (defaults to the generated filename)