Recording standalone
If you don't fall into one of the previous boxes (for example if you use another http client), you can still record the http traffic by using the standalone recording proxy, the exact same one used in the cli.
To do so, you just have to spawn the proxy and then configure your http client to use this proxy.
This requires the record
feature.
#[tokio::test(flavor = "multi_thread")]
async fn record_standalone() {
// 👇 spawn the recording proxy
let proxy = stubr::Stubr::record();
// or use `record_with()` for configuring it
let _proxy_uri = proxy.uri();
// ☝️ then use this uri to configure your http client
}
Or, in order to keep the syntax short, you can use the provided attribute macro.
// works for async as well
#[stubr::record] // 👈 this spawns the proxy and creates a 'recorder' binding in the function
// #[stubr::record(port = 1234)] for setting a port
#[test]
fn record_standalone() {
let _proxy_uri = recorder.uri();
// ☝️ then use this uri to configure your http client
}