#[cfg(feature = "emulation")]
use futures_lite::future::block_on;
#[cfg(feature = "emulation")]
use serde_json::Value;
#[cfg(feature = "emulation")]
fn main() -> Result<(), Box<dyn std::error::Error>> {
block_on(async move {
let client = ugi::Client::builder()
.emulation(ugi::Emulation::Chrome136)
.build()?;
let response = client.get("https://tls.peet.ws/api/all").await?;
let payload: Value = response.json().await?;
println!(
"http_version={}",
payload["http_version"].as_str().unwrap_or("unknown")
);
println!(
"user_agent={}",
payload["user_agent"].as_str().unwrap_or("unknown")
);
Ok(())
})
}
#[cfg(not(feature = "emulation"))]
fn main() {
eprintln!(
"This example requires the `emulation` feature:\n cargo run --example emulation_preset --features emulation"
);
}