use anyhow::Result; use std::collections::HashMap; use dx_http::{ClientConfig, DxHttpClient, Todo}; #[tokio::main] async fn main() -> Result<()> { let config = ClientConfig { base_url: Some("https://jsonplaceholder.typicode.com".to_string()), ..Default::default() }; let client = DxHttpClient::new(config)?; // GET request with Todo struct let todo: Todo = client.get("/todos/1").await?; println!("GET Todo result: {:?}", todo); // GET request with dynamic JSON let dynamic_json: serde_json::Value = client.get("/todos/1").await?; println!("GET dynamic JSON result: {:?}", dynamic_json); // GET request with HashMap let hashmap_result: HashMap = client.get("/todos/1").await?; println!("GET HashMap result: {:?}", hashmap_result); // POST request with Todo struct let new_todo = Todo { id: 0, title: "My new todo".to_string(), completed: false, }; let created_todo: Todo = client.post("/todos", &new_todo).await?; println!("POST result: {:?}", created_todo); // POST request with dynamic JSON let dynamic_body = serde_json::json!({ "title": "Dynamic todo", "completed": false }); let dynamic_result: serde_json::Value = client.post("/todos", &dynamic_body).await?; println!("POST dynamic result: {:?}", dynamic_result); Ok(()) }