Skip to main content

get

Function get 

Source
pub fn get(url: &str) -> HttpClient
Examples found in repository?
examples/demo.rs (line 6)
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}