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

update examples

This commit is contained in:
Nikolay Kim
2019-11-26 17:16:33 +06:00
parent f73f97353b
commit f2b3dc5625
4 changed files with 27 additions and 23 deletions

View File

@ -1,27 +1,25 @@
use actix_http::Error;
use actix_rt::System;
fn main() -> Result<(), Error> {
#[actix_rt::main]
async fn main() -> Result<(), Error> {
std::env::set_var("RUST_LOG", "actix_http=trace");
env_logger::init();
System::new("test").block_on(async {
let client = awc::Client::new();
let client = awc::Client::new();
// Create request builder, configure request and send
let mut response = client
.get("https://www.rust-lang.org/")
.header("User-Agent", "Actix-web")
.send()
.await?;
// Create request builder, configure request and send
let mut response = client
.get("https://www.rust-lang.org/")
.header("User-Agent", "Actix-web")
.send()
.await?;
// server http response
println!("Response: {:?}", response);
// server http response
println!("Response: {:?}", response);
// read response body
let body = response.body().await?;
println!("Downloaded: {:?} bytes", body.len());
// read response body
let body = response.body().await?;
println!("Downloaded: {:?} bytes", body.len());
Ok(())
})
Ok(())
}