1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-12-20 23:26:44 +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
## Example
```rust
use actix_rt::System;
use awc::Client;
use futures::future::{Future, lazy};
fn main() {
System::new("test").block_on(lazy(|| {
let mut client = Client::default();
System::new("test").block_on(async {
let client = Client::default();
client.get("http://www.rust-lang.org") // <- Create request builder
.header("User-Agent", "Actix-web")
.send() // <- Send http request
.and_then(|response| { // <- server http response
println!("Response: {:?}", response);
Ok(())
})
}));
let res = client
.get("http://www.rust-lang.org") // <- Create request builder
.header("User-Agent", "Actix-web")
.send() // <- Send http request
.await;
println!("Response: {:?}", res); // <- server http response
});
}
```