1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-25 06:39:22 +02:00

use tokio::main in client example

This commit is contained in:
Rob Ede
2022-01-19 21:36:14 +00:00
parent 1cc3e7b24c
commit 1bc1538118
5 changed files with 39 additions and 31 deletions

View File

@ -1,13 +1,13 @@
use std::error::Error as StdError;
#[actix_web::main]
#[tokio::main]
async fn main() -> Result<(), Box<dyn StdError>> {
std::env::set_var("RUST_LOG", "client=trace,awc=trace,actix_http=trace");
env_logger::init();
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
// construct request builder
let client = awc::Client::new();
// Create request builder, configure request and send
// configure request
let request = client
.get("https://www.rust-lang.org/")
.append_header(("User-Agent", "Actix-web"));
@ -16,7 +16,7 @@ async fn main() -> Result<(), Box<dyn StdError>> {
let mut response = request.send().await?;
// server http response
// server response head
println!("Response: {:?}", response);
// read response body