fix awc doc example

This commit is contained in:
fakeshadow 2020-11-05 02:19:41 +08:00
parent 61b65aa64a
commit 2a67211621
1 changed files with 12 additions and 14 deletions

View File

@ -16,23 +16,21 @@
- Minimum Supported Rust Version (MSRV): 1.42.0 - Minimum Supported Rust Version (MSRV): 1.42.0
## Example ## Example
```rust ```rust
use actix_rt::System; use actix_web::client::Client;
use awc::Client; use actix_web::rt::System;
use futures::future::{Future, lazy};
fn main() { fn main() {
System::new("test").block_on(lazy(|| { System::new("test").block_on(async {
let mut client = Client::default(); let client = Client::default();
client.get("http://www.rust-lang.org") // <- Create request builder let res = client
.header("User-Agent", "Actix-web") .get("http://www.rust-lang.org") // <- Create request builder
.send() // <- Send http request .header("User-Agent", "Actix-web")
.and_then(|response| { // <- server http response .send() // <- Send http request
println!("Response: {:?}", response); .await;
Ok(())
}) println!("Response: {:?}", res); // <- server http response
})); });
} }
``` ```