awc: new fetch api
This commit is contained in:
parent
e7a34dd33b
commit
1718b90083
|
@ -100,11 +100,11 @@ where
|
|||
|
||||
async fn do_fetch<Id: Dereference>(
|
||||
&self,
|
||||
id: &Id,
|
||||
url: &Url,
|
||||
) -> Result<Option<<Id as Dereference>::Output>, AwcError<SignError<Crypto>>> {
|
||||
let mut response = self
|
||||
.client
|
||||
.get(id.url().as_str())
|
||||
.get(url.as_str())
|
||||
.insert_header(("Accept", "application/activity+json"))
|
||||
.insert_header(("Date", HttpDate::from(SystemTime::now())))
|
||||
.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>,
|
||||
>;
|
||||
|
||||
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