mirror of https://github.com/fafhrd91/actix-web
				
				
				
			
		
			
				
	
	
		
			39 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Markdown
		
	
	
	
			
		
		
	
	
			39 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Markdown
		
	
	
	
| # `awc` (Actix Web Client)
 | |
| 
 | |
| > Async HTTP and WebSocket client library.
 | |
| 
 | |
| <!-- prettier-ignore-start -->
 | |
| 
 | |
| [](https://crates.io/crates/awc)
 | |
| [](https://docs.rs/awc/3.8.1)
 | |
| 
 | |
| [](https://deps.rs/crate/awc/3.8.1)
 | |
| [](https://discord.gg/NWpN5mmg3x)
 | |
| 
 | |
| <!-- prettier-ignore-end -->
 | |
| 
 | |
| ## Examples
 | |
| 
 | |
| [Example project using TLS-enabled client →](https://github.com/actix/examples/tree/master/https-tls/awc-https)
 | |
| 
 | |
| Basic usage:
 | |
| 
 | |
| ```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
 | |
|             .insert_header(("User-Agent", "Actix-web"))
 | |
|             .send()                             // <- Send http request
 | |
|             .await;
 | |
| 
 | |
|         println!("Response: {:?}", res);        // <- server http response
 | |
|     });
 | |
| }
 | |
| ```
 |