Environment: addon_transport added, with default impl
@@ -2,7 +2,7 @@ use futures::Future;
use serde::de::DeserializeOwned;
use serde::Serialize;
use std::error::Error;
-use crate::types::addons::{ResourceRequest, ResourceResponse};
+use crate::types::addons::TransportUrl;
use crate::addon_transport::{AddonHTTPTransport, AddonInterface};
pub use http::Request;
@@ -17,9 +17,9 @@ pub trait Environment {
fn exec(fut: Box<Future<Item = (), Error = ()>>);
fn get_storage<T: 'static + DeserializeOwned>(key: &str) -> EnvFuture<Option<T>>;
fn set_storage<T: 'static + Serialize>(key: &str, value: Option<&T>) -> EnvFuture<()>;
- fn fetch_addon(req: &ResourceRequest) -> EnvFuture<ResourceResponse>
- where Self: Sized
+ fn addon_transport(url: &TransportUrl) -> Box<dyn AddonInterface>
+ where Self: Sized + 'static
{
- AddonHTTPTransport::<Self>::from_url(&req.transport_url).get(&req.resource_ref)
+ Box::new(AddonHTTPTransport::<Self>::from_url(url))
}
}
