2019-03-28 20:46:26 +00:00
|
|
|
# Actix http client [![Build Status](https://travis-ci.org/actix/actix-web.svg?branch=master)](https://travis-ci.org/actix/actix-web) [![codecov](https://codecov.io/gh/actix/actix-web/branch/master/graph/badge.svg)](https://codecov.io/gh/actix/actix-web) [![crates.io](https://meritbadge.herokuapp.com/awc)](https://crates.io/crates/awc) [![Join the chat at https://gitter.im/actix/actix](https://badges.gitter.im/actix/actix.svg)](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
2019-04-16 17:49:38 +00: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 17:50:37 +00:00
|
|
|
* Cargo package: [awc](https://crates.io/crates/awc)
|
2019-04-16 17:49:38 +00:00
|
|
|
* Minimum supported Rust version: 1.33 or later
|
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
```rust
|
|
|
|
use actix_rt::System;
|
|
|
|
use awc::Client;
|
2019-04-16 17:50:37 +00:00
|
|
|
use futures::future::{Future, lazy};
|
2019-04-16 17:49:38 +00: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(())
|
|
|
|
})
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
```
|