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:
parent
ceac97bb8d
commit
9b6a089b36
1 changed files with 10 additions and 12 deletions
|
@ -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
|
||||||
|
.get("http://www.rust-lang.org") // <- Create request builder
|
||||||
.header("User-Agent", "Actix-web")
|
.header("User-Agent", "Actix-web")
|
||||||
.send() // <- Send http request
|
.send() // <- Send http request
|
||||||
.and_then(|response| { // <- server http response
|
.await;
|
||||||
println!("Response: {:?}", response);
|
|
||||||
Ok(())
|
println!("Response: {:?}", res); // <- server http response
|
||||||
})
|
});
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in a new issue