back to stable async-std + use surf instead of reqwest

removes tokio from our dependency tree, now only one async executor
This commit is contained in:
dignifiedquire
2020-05-22 11:10:26 +02:00
parent c43e7cdbdc
commit 70a2dbb4bb
10 changed files with 258 additions and 445 deletions

View File

@@ -3,17 +3,13 @@ use crate::context::Context;
#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("URL request error")]
GetError(#[from] reqwest::Error),
GetError(surf::Error),
}
pub fn read_url(context: &Context, url: &str) -> Result<String, Error> {
pub async fn read_url(context: &Context, url: &str) -> Result<String, Error> {
info!(context, "Requesting URL {}", url);
match reqwest::blocking::Client::new()
.get(url)
.send()
.and_then(|res| res.text())
{
match surf::get(url).recv_string().await {
Ok(res) => Ok(res),
Err(err) => {
info!(context, "Can\'t read URL {}", url);