From acb86966394e5315d507e095762c72b702812520 Mon Sep 17 00:00:00 2001 From: "Aode (lion)" Date: Mon, 22 Nov 2021 16:50:57 -0600 Subject: [PATCH] reqwest: new fetch api --- apub-reqwest/src/lib.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/apub-reqwest/src/lib.rs b/apub-reqwest/src/lib.rs index 0c31ce4..0d12fb0 100644 --- a/apub-reqwest/src/lib.rs +++ b/apub-reqwest/src/lib.rs @@ -90,14 +90,14 @@ where async fn do_fetch( &self, - id: &Id, + url: &Url, ) -> Result::Output>, ReqwestError>> where Id: Dereference, { let response = self .client - .get(id.url().as_str()) + .get(url.as_str()) .header(ACCEPT, "application/activity+json") .header(DATE, httpdate::fmt_http_date(SystemTime::now())) .signature(self.config, self.crypto.key_id(), { @@ -114,7 +114,7 @@ where impl<'a, Id, CurrentSession, Crypto> Repo<'a, Id> for ReqwestClient<'a, CurrentSession, Crypto> where - Id: Dereference + Send + Sync, + Id: Dereference + Send + Sync + 'a, ::Output: 'static, CurrentSession: Session + Send + Sync, Crypto: SignFactory + Send + Sync, @@ -129,12 +129,10 @@ where >, >; - fn fetch(&'a self, id: &'a Id) -> Self::Future { - Box::pin(apub_core::session::guard( - self.do_fetch(id), - id.url(), - &self.session, - )) + fn fetch(&'a self, id: Id) -> Self::Future { + Box::pin(async move { + apub_core::session::guard(self.do_fetch::(id.url()), id.url(), &self.session).await + }) } }