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:
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
|
||||
|
||||
## 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
|
||||
let res = 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(())
|
||||
})
|
||||
}));
|
||||
.await;
|
||||
|
||||
println!("Response: {:?}", res); // <- server http response
|
||||
});
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue