reqwest: new fetch api

This commit is contained in:
Aode (lion) 2021-11-22 16:50:57 -06:00
parent 3c778aae6d
commit acb8696639

View file

@ -90,14 +90,14 @@ where
async fn do_fetch<Id>(
&self,
id: &Id,
url: &Url,
) -> Result<Option<<Id as Dereference>::Output>, ReqwestError<SignTraitError<Crypto>>>
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,
<Id as Dereference>::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>(id.url()), id.url(), &self.session).await
})
}
}