Make the async Client default (#626)

The previously default Client is moved to `reqwest::blocking`, while the
async client becomes the main API.

Closes #622
This commit is contained in:
Sean McArthur
2019-09-09 17:20:51 -07:00
committed by GitHub
parent 5fb04356fc
commit 87a09322d6
30 changed files with 1110 additions and 1066 deletions

View File

@@ -4,7 +4,8 @@
//! really care about the structure of the JSON and just need to display it or
//! process it at runtime.
fn main() -> Result<(), reqwest::Error> {
#[tokio::main]
async fn main() -> Result<(), reqwest::Error> {
let echo_json: serde_json::Value = reqwest::Client::new()
.post("https://jsonplaceholder.typicode.com/posts")
.json(&serde_json::json!({
@@ -12,8 +13,10 @@ fn main() -> Result<(), reqwest::Error> {
"body": "https://docs.rs/reqwest",
"userId": 1
}))
.send()?
.json()?;
.send()
.await?
.json()
.await?;
println!("{:#?}", echo_json);
// Object(