Fix tokio implementation

This commit is contained in:
Gabriel Tofvesson 2022-12-05 12:23:40 +01:00
parent d552f4047b
commit f0f969ef4f
2 changed files with 8 additions and 4 deletions

View File

@ -33,6 +33,6 @@ surf = { version = "^2.1.0", optional=true, default-features=false}
[dev-dependencies]
mockito = "0.28.0"
maplit = "1.0.2"
tokio = { version = "^0.2.5", features = ["full"]}
tokio = { version = "^1.21.2", features = ["full"]}
env_logger = "0.8.2"
serde_json = "^1.0"

View File

@ -293,9 +293,13 @@ impl surf::middleware::Middleware for BearerToken {
#[cfg(feature = "async")]
fn async_client(token: &str, base_url: &str) -> surf::Client {
let mut async_client = surf::client();
async_client.set_base_url(surf::Url::parse(base_url).expect("Static string should parse"));
async_client.with(BearerToken::new(token))
use std::convert::TryInto;
let client: surf::Client = surf::Config::new()
.set_base_url(surf::Url::parse(base_url).expect("Could not parse base url"))
.try_into()
.expect("Could not create client");
client.with(BearerToken::new(token))
}
#[cfg(feature = "sync")]