mirror of
https://github.com/chatmail/core.git
synced 2026-04-20 23:16:30 +03:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user