diff --git a/Cargo.toml b/Cargo.toml index 4afb3c6..4433710 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libsql-client" -version = "0.31.0" +version = "0.31.1" edition = "2021" license = "Apache-2.0" description = "HTTP-based client for libSQL and sqld" @@ -31,7 +31,7 @@ tracing = "0.1.37" futures = "0.3.28" [features] -default = ["local_backend", "hrana_backend", "reqwest_backend"] +default = ["local_backend", "reqwest_backend"] workers_backend = ["worker", "futures-util"] reqwest_backend = ["reqwest"] local_backend = ["rusqlite"] diff --git a/src/client.rs b/src/client.rs index 452db64..934fad9 100644 --- a/src/client.rs +++ b/src/client.rs @@ -182,7 +182,14 @@ impl Client { /// # } /// ``` #[allow(unreachable_patterns)] - pub async fn from_config<'a>(config: Config) -> anyhow::Result { + pub async fn from_config<'a>(mut config: Config) -> anyhow::Result { + config.url = if config.url.scheme() == "libsql" { + // We cannot use url::Url::set_scheme() because it prevents changing the scheme to http... + // Safe to unwrap, because we know that the scheme is libsql + url::Url::parse(&config.url.as_str().replace("libsql://", "https://")).unwrap() + } else { + config.url + }; let scheme = config.url.scheme(); Ok(match scheme { #[cfg(feature = "local_backend")] @@ -194,19 +201,6 @@ impl Client { Client::Hrana(crate::hrana::Client::from_config(config).await?) }, #[cfg(feature = "reqwest_backend")] - "libsql" => { - let inner = crate::http::InnerClient::Reqwest(crate::reqwest::HttpClient::new()); - let mut config = config; - config.url = if config.url.scheme() == "libsql" { - // We cannot use url::Url::set_scheme() because it prevents changing the scheme to http... - // Safe to unwrap, because we know that the scheme is libsql - url::Url::parse(&config.url.as_str().replace("libsql://", "https://")).unwrap() - } else { - config.url - }; - Client::Http(crate::http::Client::from_config(inner, config)?) - } - #[cfg(feature = "reqwest_backend")] "http" | "https" => { let inner = crate::http::InnerClient::Reqwest(crate::reqwest::HttpClient::new()); Client::Http(crate::http::Client::from_config(inner, config)?)