1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-21 07:36:43 +00:00

fix awc doc example (#1772)

* fix awc readme example

Co-authored-by: Rob Ede <robjtede@icloud.com>
This commit is contained in:
fakeshadow 2020-11-05 06:20:01 +08:00 committed by GitHub
parent ceac97bb8d
commit 9b6a089b36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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_rt::System;
use awc::Client; use awc::Client;
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
})); });
} }
``` ```