1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-01-19 06:04:40 +01:00
actix-web/awc/README.md

39 lines
1.2 KiB
Markdown
Raw Normal View History

2024-01-10 04:00:20 +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
2024-01-10 04:00:20 +00:00
<!-- prettier-ignore-start -->
2020-10-30 02:50:53 +00:00
[![crates.io](https://img.shields.io/crates/v/awc?label=latest)](https://crates.io/crates/awc)
2024-02-04 00:32:57 +00:00
[![Documentation](https://docs.rs/awc/badge.svg?version=3.4.0)](https://docs.rs/awc/3.4.0)
2021-02-10 12:10:03 +00:00
![MIT or Apache 2.0 licensed](https://img.shields.io/crates/l/awc)
2024-02-04 00:32:57 +00:00
[![Dependency Status](https://deps.rs/crate/awc/3.4.0/status.svg)](https://deps.rs/crate/awc/3.4.0)
2021-06-26 16:33:36 +01:00
[![Chat on Discord](https://img.shields.io/discord/771444961383153695?label=chat&logo=discord)](https://discord.gg/NWpN5mmg3x)
2019-04-16 10:49:38 -07:00
2024-01-10 04:00:20 +00:00
<!-- prettier-ignore-end -->
## Examples
2020-10-30 02:50:53 +00:00
[Example project using TLS-enabled client →](https://github.com/actix/examples/tree/master/https-tls/awc-https)
2019-04-16 10:49:38 -07:00
Basic usage:
2019-04-16 10:49:38 -07:00
```rust
use actix_rt::System;
use awc::Client;
fn main() {
System::new().block_on(async {
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"))
.send() // <- Send http request
.await;
println!("Response: {:?}", res); // <- server http response
});
2019-04-16 10:49:38 -07:00
}
```