get_a_thousand_status_codes/src/main.rs
2020-08-17 14:19:16 +02:00

18 lines
626 B
Rust

#[tokio::main]
async fn main() {
let mut handles = Vec::with_capacity(1000);
for url in include_str!("../test-urls.txt").split("\n") {
handles.push(tokio::spawn(async move {
match reqwest::ClientBuilder::new().user_agent("Test/contact: admin@cryto.net").build().unwrap().get(url).send().await.and_then(|resp| {
Ok(resp.status())
}) {
Ok(status) => println!("{}, {}", status, chrono::Utc::now()),
Err(_) => eprintln!("Something went wrong here"),
};
}));
}
for handle in handles {
handle.await;
}
}