2019-03-28 13:46:26 -07:00
|
|
|
# Actix http client [](https://travis-ci.org/actix/actix-web) [](https://codecov.io/gh/actix/actix-web) [](https://crates.io/crates/awc) [](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
2019-04-16 10:49:38 -07:00
|
|
|
|
|
|
|
An HTTP Client
|
|
|
|
|
|
|
|
## Documentation & community resources
|
|
|
|
|
|
|
|
* [User Guide](https://actix.rs/docs/)
|
|
|
|
* [API Documentation](https://docs.rs/awc/)
|
|
|
|
* [Chat on gitter](https://gitter.im/actix/actix)
|
2019-04-16 10:50:37 -07:00
|
|
|
* Cargo package: [awc](https://crates.io/crates/awc)
|
2019-04-16 10:49:38 -07:00
|
|
|
* Minimum supported Rust version: 1.33 or later
|
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
```rust
|
|
|
|
use actix_rt::System;
|
|
|
|
use awc::Client;
|
2019-04-16 10:50:37 -07:00
|
|
|
use futures::future::{Future, lazy};
|
2019-04-16 10:49:38 -07:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
System::new("test").block_on(lazy(|| {
|
|
|
|
let mut 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(())
|
|
|
|
})
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
```
|