use dotenvy::dotenv;
use kode_bridge::{IpcHttpClient, Result};
use std::env;
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<()> {
dotenv().ok();
#[cfg(unix)]
let ipc_path = env::var("CUSTOM_SOCK").unwrap_or_else(|_| "/tmp/example.sock".to_string());
#[cfg(windows)]
let ipc_path = env::var("CUSTOM_PIPE").unwrap_or_else(|_| r"\\.\pipe\example".to_string());
println!("📡 Connecting to: {}", ipc_path);
let client = IpcHttpClient::new(&ipc_path)?;
let response = client
.get("/version")
.header("foo", "bar")
.timeout(Duration::from_secs(10))
.send()
.await?;
println!("🔍 Response Details:");
println!(" Status: {}", response.status());
println!(" Success: {}", response.is_success());
println!(" Content Length: {}", response.content_length());
match response.json_value() {
Ok(json) => println!("📄 JSON Response: {:#}", json),
Err(e) => {
println!("📄 Raw Response: {:?}", response.body()?);
println!("⚠️ JSON parse error: {}", e);
}
}
if let Some(stats) = client.pool_stats() {
println!("📊 Pool Stats: {}", stats);
}
drop(client);
Ok(())
}