reqwest: new fetch api
This commit is contained in:
parent
3c778aae6d
commit
acb8696639
1 changed files with 7 additions and 9 deletions
|
@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue