demo/demo.rs
1use maestro_http::{get, post};
2
3#[tokio::main]
4async fn main() {
5 // GET
6 let html = get("https://example.com")
7 .timeout(10)
8 .text()
9 .await
10 .unwrap();
11
12 println!("HTML:\n{}", html);
13
14 // POST JSON
15 let data = serde_json::json!({
16 "name": "Maestro"
17 });
18
19 let res = post("https://httpbin.org/post")
20 .header("Content-Type", "application/json")
21 .json(&data)
22 .await
23 .unwrap();
24
25 println!("POST response:\n{}", res);
26
27}