2020-10-30 02:50:53 +00:00
|
|
|
# awc (Actix Web Client)
|
2019-04-16 10:49:38 -07:00
|
|
|
|
2020-10-30 02:50:53 +00:00
|
|
|
> Async HTTP and WebSocket client library.
|
2019-04-16 10:49:38 -07:00
|
|
|
|
2020-10-30 02:50:53 +00:00
|
|
|
[](https://crates.io/crates/awc)
|
2023-02-26 03:34:47 +00:00
|
|
|
[](https://docs.rs/awc/3.1.1)
|
2021-02-10 12:10:03 +00:00
|
|
|

|
2023-02-26 03:34:47 +00:00
|
|
|
[](https://deps.rs/crate/awc/3.1.1)
|
2021-06-26 16:33:36 +01:00
|
|
|
[](https://discord.gg/NWpN5mmg3x)
|
2019-04-16 10:49:38 -07:00
|
|
|
|
2020-10-30 02:50:53 +00:00
|
|
|
## Documentation & Resources
|
|
|
|
|
2020-11-25 00:07:56 +00:00
|
|
|
- [API Documentation](https://docs.rs/awc)
|
2022-02-18 03:41:10 +00:00
|
|
|
- [Example Project](https://github.com/actix/examples/tree/master/https-tls/awc-https)
|
2023-07-02 01:09:15 +01:00
|
|
|
- Minimum Supported Rust Version (MSRV): 1.65
|
2019-04-16 10:49:38 -07:00
|
|
|
|
|
|
|
## Example
|
2021-02-28 18:41:07 -03:00
|
|
|
|
2019-04-16 10:49:38 -07:00
|
|
|
```rust
|
|
|
|
use actix_rt::System;
|
|
|
|
use awc::Client;
|
|
|
|
|
|
|
|
fn main() {
|
2021-02-06 17:00:40 -08:00
|
|
|
System::new().block_on(async {
|
2020-11-05 06:20:01 +08:00
|
|
|
let client = Client::default();
|
|
|
|
|
|
|
|
let res = client
|
|
|
|
.get("http://www.rust-lang.org") // <- Create request builder
|
2021-03-15 03:59:42 -07:00
|
|
|
.insert_header(("User-Agent", "Actix-web"))
|
2020-11-05 06:20:01 +08:00
|
|
|
.send() // <- Send http request
|
|
|
|
.await;
|
|
|
|
|
|
|
|
println!("Response: {:?}", res); // <- server http response
|
|
|
|
});
|
2019-04-16 10:49:38 -07:00
|
|
|
}
|
|
|
|
```
|