awc: new fetch api
This commit is contained in:
parent
e7a34dd33b
commit
1718b90083
|
@ -100,11 +100,11 @@ where
|
||||||
|
|
||||||
async fn do_fetch<Id: Dereference>(
|
async fn do_fetch<Id: Dereference>(
|
||||||
&self,
|
&self,
|
||||||
id: &Id,
|
url: &Url,
|
||||||
) -> Result<Option<<Id as Dereference>::Output>, AwcError<SignError<Crypto>>> {
|
) -> Result<Option<<Id as Dereference>::Output>, AwcError<SignError<Crypto>>> {
|
||||||
let mut response = self
|
let mut response = self
|
||||||
.client
|
.client
|
||||||
.get(id.url().as_str())
|
.get(url.as_str())
|
||||||
.insert_header(("Accept", "application/activity+json"))
|
.insert_header(("Accept", "application/activity+json"))
|
||||||
.insert_header(("Date", HttpDate::from(SystemTime::now())))
|
.insert_header(("Date", HttpDate::from(SystemTime::now())))
|
||||||
.signature(self.config.clone(), self.crypto.key_id(), {
|
.signature(self.config.clone(), self.crypto.key_id(), {
|
||||||
|
@ -132,12 +132,10 @@ where
|
||||||
Box<dyn Future<Output = Result<Option<<Id as Dereference>::Output>, Self::Error>> + 'a>,
|
Box<dyn Future<Output = Result<Option<<Id as Dereference>::Output>, Self::Error>> + 'a>,
|
||||||
>;
|
>;
|
||||||
|
|
||||||
fn fetch(&'a self, id: &'a Id) -> Self::Future {
|
fn fetch(&'a self, id: Id) -> Self::Future {
|
||||||
Box::pin(apub_core::session::guard(
|
Box::pin(async move {
|
||||||
self.do_fetch(id),
|
apub_core::session::guard(self.do_fetch::<Id>(id.url()), id.url(), &self.session).await
|
||||||
id.url(),
|
})
|
||||||
&self.session,
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue