http-rs / surf

Fast and friendly HTTP client framework for async Rust
https://docs.rs/surf
Apache License 2.0
1.45k stars 119 forks source link

Proposal: VCR-style request/response mocking middleware for testing #299

Open jbr opened 3 years ago

jbr commented 3 years ago

This would entail an external crate that provides a surf middleware with two modes (or potentially two different middlewares)

When it's in recording mode, it transparently writes all requests and responses to disk in a configurable well-known location in a human-readable and editable format of some sort. When it's in playback mode, instead of making requests against external servers, it responds with the data from disk

references:

yoshuawuyts commented 3 years ago

That would be amazing, and I think an excellent use of Surf middleware!

jbr commented 3 years ago

In case anyone sees this and is unclear what stage this proposal is at: I am not currently working on this, and will update this issue if I start. I encourage others to do likewise

rjframe commented 3 years ago

I'm working on this; I have a basic middleware working at https://github.com/rjframe/surf-vcr. I've only done minimal testing thus far but will be doing more in the next week or two.