👏

0001 reqwest-http

に公開
use reqwest;
use anyhow::Result;
#[tokio::main]
async fn main() -> Result<()>{
    let url = "https://google.com";
    let res = reqwest::get(url).await?;
    assert!(res.status().is_success());
    println!("{}", res.status());
    let _body = res.text().await?;
    //println!("{body}");
    Ok(())
}

cargo.tomp

[package]
name = "http_client-sample"
version = "0.1.0"
edition = "2024"

[dependencies]
reqwest = { version = "0.12", features = ["json"] }
tokio = { version = "1", features = ["full"] }
anyhow = "1.0"

Discussion