Use blocking reqwest API in defer

defer, or, trait functions such as it in general(?) cannot be async (yet)
This commit is contained in:
Igor Galić 2020-01-29 13:08:20 +01:00
parent 25c5da1a7c
commit a3f165f9f4
No known key found for this signature in database
GPG Key ID: ACFEFF7F6A123A86
4 changed files with 12 additions and 3 deletions

1
Cargo.lock generated
View File

@ -3180,6 +3180,7 @@ dependencies = [
"percent-encoding 2.1.0",
"pin-project-lite",
"serde",
"serde_json",
"serde_urlencoded 0.6.1",
"time",
"tokio 0.2.20",

View File

@ -16,7 +16,6 @@ hex = "0.3"
hyper = "0.13"
openssl = "0.10.22"
rocket = { git = "https://github.com/SergioBenitez/Rocket", rev = "async" }
reqwest = "0.10"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
@ -32,3 +31,7 @@ version = "0.4"
[dependencies.pulldown-cmark]
default-features = false
version = "0.2.0"
[dependencies.reqwest]
features = ["json", "blocking"]
version = "0.10"

View File

@ -279,7 +279,8 @@ pub trait FromId<C>: Sized {
/// Dereferences an ID
fn deref(id: &str) -> Result<Self::Object, (Option<serde_json::Value>, Self::Error)> {
reqwest::ClientBuilder::new()
// Use blocking reqwest API here, since defer cannot be async (yet)
reqwest::blocking::Client::builder()
.connect_timeout(std::time::Duration::from_secs(5))
.build()
.map_err(|_| (None, InboxError::DerefError.into()))?

View File

@ -16,7 +16,6 @@ lazy_static = "1.0"
migrations_internals= "1.4.0"
openssl = "0.10.22"
rocket = { git = "https://github.com/SergioBenitez/Rocket", rev = "async" }
reqwest = "0.10"
scheduled-thread-pool = "0.2.2"
serde = "1.0"
serde_derive = "1.0"
@ -47,6 +46,11 @@ path = "../plume-common"
[dependencies.plume-macro]
path = "../plume-macro"
[dependencies.reqwest]
features = ["json", "blocking"]
version = "0.10"
[dependencies.rocket_i18n]
git = "https://github.com/Plume-org/rocket_i18n"
branch = "go-async"