2020-10-30 03:50:53 +01:00
|
|
|
# awc (Actix Web Client)
|
2019-04-16 19:49:38 +02:00
|
|
|
|
2020-10-30 03:50:53 +01:00
|
|
|
> Async HTTP and WebSocket client library.
|
2019-04-16 19:49:38 +02:00
|
|
|
|
2020-10-30 03:50:53 +01:00
|
|
|
[![crates.io](https://img.shields.io/crates/v/awc?label=latest)](https://crates.io/crates/awc)
|
2021-11-15 05:03:33 +01:00
|
|
|
[![Documentation](https://docs.rs/awc/badge.svg?version=3.0.0-beta.10)](https://docs.rs/awc/3.0.0-beta.10)
|
2021-02-10 13:10:03 +01:00
|
|
|
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/awc)
|
2021-11-15 05:03:33 +01:00
|
|
|
[![Dependency Status](https://deps.rs/crate/awc/3.0.0-beta.10/status.svg)](https://deps.rs/crate/awc/3.0.0-beta.10)
|
2021-06-26 17:33:36 +02:00
|
|
|
[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)
|
2019-04-16 19:49:38 +02:00
|
|
|
|
2020-10-30 03:50:53 +01:00
|
|
|
## Documentation & Resources
|
|
|
|
|
2020-11-25 01:07:56 +01:00
|
|
|
- [API Documentation](https://docs.rs/awc)
|
2021-02-28 22:41:07 +01:00
|
|
|
- [Example Project](https://github.com/actix/examples/tree/HEAD/security/awc_https)
|
2021-10-19 02:59:28 +02:00
|
|
|
- Minimum Supported Rust Version (MSRV): 1.52
|
2019-04-16 19:49:38 +02:00
|
|
|
|
|
|
|
## Example
|
2021-02-28 22:41:07 +01:00
|
|
|
|
2019-04-16 19:49:38 +02:00
|
|
|
```rust
|
|
|
|
use actix_rt::System;
|
|
|
|
use awc::Client;
|
|
|
|
|
|
|
|
fn main() {
|
2021-02-07 02:00:40 +01:00
|
|
|
System::new().block_on(async {
|
2020-11-04 23:20:01 +01:00
|
|
|
let client = Client::default();
|
|
|
|
|
|
|
|
let res = client
|
|
|
|
.get("http://www.rust-lang.org") // <- Create request builder
|
2021-03-15 11:59:42 +01:00
|
|
|
.insert_header(("User-Agent", "Actix-web"))
|
2020-11-04 23:20:01 +01:00
|
|
|
.send() // <- Send http request
|
|
|
|
.await;
|
|
|
|
|
|
|
|
println!("Response: {:?}", res); // <- server http response
|
|
|
|
});
|
2019-04-16 19:49:38 +02:00
|
|
|
}
|
|
|
|
```
|