2017-01-25 18:51:41 +01:00
|
|
|
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
2016-04-07 12:10:26 +02:00
|
|
|
// This file is part of Parity.
|
|
|
|
|
|
|
|
// Parity is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// Parity is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
//! Router implementation
|
2017-04-03 10:27:37 +02:00
|
|
|
//! Dispatch requests to proper application.
|
2016-04-07 12:10:26 +02:00
|
|
|
|
2016-12-27 11:15:02 +01:00
|
|
|
use std::cmp;
|
2017-04-05 11:37:45 +02:00
|
|
|
use std::sync::Arc;
|
2016-05-13 18:40:20 +02:00
|
|
|
use std::collections::HashMap;
|
2017-03-22 07:02:14 +01:00
|
|
|
|
2016-07-07 09:42:49 +02:00
|
|
|
use url::{Url, Host};
|
2017-05-24 12:24:07 +02:00
|
|
|
use hyper::{self, server, header, Control};
|
2016-04-14 20:38:48 +02:00
|
|
|
use hyper::net::HttpStream;
|
2017-04-03 10:27:37 +02:00
|
|
|
use jsonrpc_http_server as http;
|
2017-03-22 07:02:14 +01:00
|
|
|
|
2017-05-24 12:24:07 +02:00
|
|
|
use apps;
|
2016-12-22 18:26:39 +01:00
|
|
|
use apps::fetcher::Fetcher;
|
2017-04-03 10:27:37 +02:00
|
|
|
use endpoint::{Endpoint, Endpoints, EndpointPath, Handler};
|
2017-05-24 12:24:07 +02:00
|
|
|
use handlers;
|
2016-04-07 18:22:53 +02:00
|
|
|
|
2016-05-13 18:40:20 +02:00
|
|
|
/// Special endpoints are accessible on every domain (every dapp)
|
|
|
|
#[derive(Debug, PartialEq, Hash, Eq)]
|
|
|
|
pub enum SpecialEndpoint {
|
2016-05-12 17:13:26 +02:00
|
|
|
Rpc,
|
|
|
|
Api,
|
2016-05-13 18:40:20 +02:00
|
|
|
Utils,
|
2017-05-24 12:24:07 +02:00
|
|
|
Home,
|
2016-05-16 20:22:19 +02:00
|
|
|
None,
|
2016-05-12 17:13:26 +02:00
|
|
|
}
|
|
|
|
|
2017-04-05 11:37:45 +02:00
|
|
|
pub struct Router {
|
2017-05-24 12:24:07 +02:00
|
|
|
endpoints: Option<Endpoints>,
|
2017-04-05 11:37:45 +02:00
|
|
|
fetch: Arc<Fetcher>,
|
2017-04-03 10:27:37 +02:00
|
|
|
special: HashMap<SpecialEndpoint, Option<Box<Endpoint>>>,
|
2017-05-24 12:24:07 +02:00
|
|
|
embeddable_on: Option<(String, u16)>,
|
|
|
|
dapps_domain: String,
|
2016-04-07 12:10:26 +02:00
|
|
|
}
|
|
|
|
|
2017-04-05 11:37:45 +02:00
|
|
|
impl http::RequestMiddleware for Router {
|
2017-04-03 10:27:37 +02:00
|
|
|
fn on_request(&self, req: &server::Request<HttpStream>, control: &Control) -> http::RequestMiddlewareAction {
|
2016-09-01 10:16:04 +02:00
|
|
|
// Choose proper handler depending on path / domain
|
2017-04-03 10:27:37 +02:00
|
|
|
let url = handlers::extract_url(req);
|
2017-05-24 12:24:07 +02:00
|
|
|
let endpoint = extract_endpoint(&url, &self.dapps_domain);
|
|
|
|
let referer = extract_referer_endpoint(req, &self.dapps_domain);
|
2016-09-01 10:16:04 +02:00
|
|
|
let is_utils = endpoint.1 == SpecialEndpoint::Utils;
|
2017-05-24 12:24:07 +02:00
|
|
|
let is_origin_set = req.headers().get::<header::Origin>().is_some();
|
2016-12-27 11:15:02 +01:00
|
|
|
let is_get_request = *req.method() == hyper::Method::Get;
|
2017-05-24 12:24:07 +02:00
|
|
|
let is_head_request = *req.method() == hyper::Method::Head;
|
2016-09-01 10:16:04 +02:00
|
|
|
|
2016-10-22 15:21:41 +02:00
|
|
|
trace!(target: "dapps", "Routing request to {:?}. Details: {:?}", url, req);
|
|
|
|
|
2017-04-03 10:27:37 +02:00
|
|
|
let control = control.clone();
|
2016-10-22 15:21:41 +02:00
|
|
|
debug!(target: "dapps", "Handling endpoint request: {:?}", endpoint);
|
2017-04-03 10:27:37 +02:00
|
|
|
let handler: Option<Box<Handler>> = match (endpoint.0, endpoint.1, referer) {
|
2016-12-27 11:15:02 +01:00
|
|
|
// Handle invalid web requests that we can recover from
|
|
|
|
(ref path, SpecialEndpoint::None, Some((ref referer, ref referer_url)))
|
2017-01-16 10:49:27 +01:00
|
|
|
if referer.app_id == apps::WEB_PATH
|
2017-05-24 12:24:07 +02:00
|
|
|
&& self.endpoints.as_ref().map(|ep| ep.contains_key(apps::WEB_PATH)).unwrap_or(false)
|
2016-12-27 11:15:02 +01:00
|
|
|
&& !is_web_endpoint(path)
|
|
|
|
=>
|
|
|
|
{
|
|
|
|
trace!(target: "dapps", "Redirecting to correct web request: {:?}", referer_url);
|
2017-02-04 09:52:14 +01:00
|
|
|
let len = cmp::min(referer_url.path.len(), 2); // /web/<encoded>/
|
2016-12-27 11:15:02 +01:00
|
|
|
let base = referer_url.path[..len].join("/");
|
|
|
|
let requested = url.map(|u| u.path.join("/")).unwrap_or_default();
|
2017-05-24 12:24:07 +02:00
|
|
|
Some(handlers::Redirection::boxed(&format!("/{}/{}", base, requested)))
|
2016-12-27 11:15:02 +01:00
|
|
|
},
|
2016-07-20 12:34:17 +02:00
|
|
|
// First check special endpoints
|
2016-12-27 11:15:02 +01:00
|
|
|
(ref path, ref endpoint, _) if self.special.contains_key(endpoint) => {
|
2016-10-22 15:21:41 +02:00
|
|
|
trace!(target: "dapps", "Resolving to special endpoint.");
|
2016-10-20 23:41:15 +02:00
|
|
|
self.special.get(endpoint)
|
|
|
|
.expect("special known to contain key; qed")
|
2017-04-03 10:27:37 +02:00
|
|
|
.as_ref()
|
|
|
|
.map(|special| special.to_async_handler(path.clone().unwrap_or_default(), control))
|
2016-07-20 12:34:17 +02:00
|
|
|
},
|
|
|
|
// Then delegate to dapp
|
2017-05-24 12:24:07 +02:00
|
|
|
(Some(ref path), _, _) if self.endpoints.as_ref().map(|ep| ep.contains_key(&path.app_id)).unwrap_or(false) => {
|
2016-10-22 15:21:41 +02:00
|
|
|
trace!(target: "dapps", "Resolving to local/builtin dapp.");
|
2017-05-24 12:24:07 +02:00
|
|
|
Some(self.endpoints
|
|
|
|
.as_ref()
|
|
|
|
.expect("endpoints known to be set; qed")
|
|
|
|
.get(&path.app_id)
|
2016-12-27 11:15:02 +01:00
|
|
|
.expect("endpoints known to contain key; qed")
|
2017-04-03 10:27:37 +02:00
|
|
|
.to_async_handler(path.clone(), control))
|
2016-07-20 12:34:17 +02:00
|
|
|
},
|
2016-08-30 16:05:18 +02:00
|
|
|
// Try to resolve and fetch the dapp
|
2016-12-27 11:15:02 +01:00
|
|
|
(Some(ref path), _, _) if self.fetch.contains(&path.app_id) => {
|
2016-10-22 15:21:41 +02:00
|
|
|
trace!(target: "dapps", "Resolving to fetchable content.");
|
2017-04-03 10:27:37 +02:00
|
|
|
Some(self.fetch.to_async_handler(path.clone(), control))
|
2016-08-18 12:19:09 +02:00
|
|
|
},
|
2017-05-24 12:24:07 +02:00
|
|
|
// 404 for non-existent content (only if serving endpoints and not homepage)
|
|
|
|
(Some(ref path), _, _)
|
|
|
|
if (is_get_request || is_head_request)
|
|
|
|
&& self.endpoints.is_some()
|
|
|
|
&& path.app_id != apps::HOME_PAGE
|
|
|
|
=>
|
|
|
|
{
|
2016-10-22 15:21:41 +02:00
|
|
|
trace!(target: "dapps", "Resolving to 404.");
|
2017-05-24 12:24:07 +02:00
|
|
|
Some(Box::new(handlers::ContentHandler::error(
|
|
|
|
hyper::StatusCode::NotFound,
|
2016-09-01 11:16:19 +02:00
|
|
|
"404 Not Found",
|
2016-09-01 12:01:44 +02:00
|
|
|
"Requested content was not found.",
|
2016-10-22 15:21:41 +02:00
|
|
|
None,
|
2017-05-24 12:24:07 +02:00
|
|
|
self.embeddable_on.clone(),
|
2017-04-03 10:27:37 +02:00
|
|
|
)))
|
2016-07-20 12:34:17 +02:00
|
|
|
},
|
2017-05-24 12:24:07 +02:00
|
|
|
// Any other GET|HEAD requests to home page.
|
|
|
|
_ if (is_get_request || is_head_request) && self.special.contains_key(&SpecialEndpoint::Home) => {
|
|
|
|
self.special.get(&SpecialEndpoint::Home)
|
|
|
|
.expect("special known to contain key; qed")
|
|
|
|
.as_ref()
|
|
|
|
.map(|special| special.to_async_handler(Default::default(), control))
|
2016-08-30 16:05:18 +02:00
|
|
|
},
|
2016-07-20 12:34:17 +02:00
|
|
|
// RPC by default
|
|
|
|
_ => {
|
2016-10-22 15:21:41 +02:00
|
|
|
trace!(target: "dapps", "Resolving to RPC call.");
|
2017-04-03 10:27:37 +02:00
|
|
|
None
|
2016-04-08 15:25:20 +02:00
|
|
|
}
|
2016-04-14 20:38:48 +02:00
|
|
|
};
|
2016-05-12 14:45:09 +02:00
|
|
|
|
2017-04-03 10:27:37 +02:00
|
|
|
match handler {
|
|
|
|
Some(handler) => http::RequestMiddlewareAction::Respond {
|
2017-05-24 12:24:07 +02:00
|
|
|
should_validate_hosts: !is_utils,
|
2017-04-03 10:27:37 +02:00
|
|
|
handler: handler,
|
|
|
|
},
|
|
|
|
None => http::RequestMiddlewareAction::Proceed {
|
|
|
|
should_continue_on_invalid_cors: !is_origin_set,
|
|
|
|
},
|
|
|
|
}
|
2016-04-07 12:10:26 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-05 11:37:45 +02:00
|
|
|
impl Router {
|
2016-04-08 16:11:58 +02:00
|
|
|
pub fn new(
|
2017-04-05 11:37:45 +02:00
|
|
|
content_fetcher: Arc<Fetcher>,
|
2017-05-24 12:24:07 +02:00
|
|
|
endpoints: Option<Endpoints>,
|
2017-04-03 10:27:37 +02:00
|
|
|
special: HashMap<SpecialEndpoint, Option<Box<Endpoint>>>,
|
2017-05-24 12:24:07 +02:00
|
|
|
embeddable_on: Option<(String, u16)>,
|
|
|
|
dapps_domain: String,
|
2017-04-03 10:27:37 +02:00
|
|
|
) -> Self {
|
2016-04-07 12:10:26 +02:00
|
|
|
Router {
|
2016-04-14 20:38:48 +02:00
|
|
|
endpoints: endpoints,
|
2016-09-04 23:44:46 +02:00
|
|
|
fetch: content_fetcher,
|
2016-05-13 18:40:20 +02:00
|
|
|
special: special,
|
2017-05-24 12:24:07 +02:00
|
|
|
embeddable_on: embeddable_on,
|
|
|
|
dapps_domain: format!(".{}", dapps_domain),
|
2016-04-07 12:10:26 +02:00
|
|
|
}
|
|
|
|
}
|
2016-05-12 15:05:59 +02:00
|
|
|
}
|
2016-04-07 12:10:26 +02:00
|
|
|
|
2016-12-27 11:15:02 +01:00
|
|
|
fn is_web_endpoint(path: &Option<EndpointPath>) -> bool {
|
|
|
|
match *path {
|
|
|
|
Some(ref path) if path.app_id == apps::WEB_PATH => true,
|
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-24 12:24:07 +02:00
|
|
|
fn extract_referer_endpoint(req: &server::Request<HttpStream>, dapps_domain: &str) -> Option<(EndpointPath, Url)> {
|
2016-12-27 11:15:02 +01:00
|
|
|
let referer = req.headers().get::<header::Referer>();
|
|
|
|
|
|
|
|
let url = referer.and_then(|referer| Url::parse(&referer.0).ok());
|
|
|
|
url.and_then(|url| {
|
|
|
|
let option = Some(url);
|
2017-05-24 12:24:07 +02:00
|
|
|
extract_url_referer_endpoint(&option, dapps_domain).or_else(|| {
|
|
|
|
extract_endpoint(&option, dapps_domain).0.map(|endpoint| (endpoint, option.expect("Just wrapped; qed")))
|
2017-01-16 10:49:27 +01:00
|
|
|
})
|
2016-12-27 11:15:02 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2017-05-24 12:24:07 +02:00
|
|
|
fn extract_url_referer_endpoint(url: &Option<Url>, dapps_domain: &str) -> Option<(EndpointPath, Url)> {
|
2017-01-16 10:49:27 +01:00
|
|
|
let query = url.as_ref().and_then(|url| url.query.as_ref());
|
|
|
|
match (url, query) {
|
|
|
|
(&Some(ref url), Some(ref query)) if query.starts_with(apps::URL_REFERER) => {
|
|
|
|
let referer_url = format!("http://{}:{}/{}", url.host, url.port, &query[apps::URL_REFERER.len()..]);
|
|
|
|
debug!(target: "dapps", "Recovering referer from query parameter: {}", referer_url);
|
|
|
|
|
|
|
|
let referer_url = Url::parse(&referer_url).ok();
|
2017-05-24 12:24:07 +02:00
|
|
|
extract_endpoint(&referer_url, dapps_domain).0.map(|endpoint| {
|
2017-01-16 10:49:27 +01:00
|
|
|
(endpoint, referer_url.expect("Endpoint returned only when url `is_some`").clone())
|
|
|
|
})
|
|
|
|
},
|
|
|
|
_ => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-24 12:24:07 +02:00
|
|
|
fn extract_endpoint(url: &Option<Url>, dapps_domain: &str) -> (Option<EndpointPath>, SpecialEndpoint) {
|
2016-05-12 17:13:26 +02:00
|
|
|
fn special_endpoint(url: &Url) -> SpecialEndpoint {
|
|
|
|
if url.path.len() <= 1 {
|
|
|
|
return SpecialEndpoint::None;
|
|
|
|
}
|
2016-05-13 18:40:20 +02:00
|
|
|
|
2016-05-12 17:13:26 +02:00
|
|
|
match url.path[0].as_ref() {
|
2016-05-13 18:40:20 +02:00
|
|
|
apps::RPC_PATH => SpecialEndpoint::Rpc,
|
|
|
|
apps::API_PATH => SpecialEndpoint::Api,
|
|
|
|
apps::UTILS_PATH => SpecialEndpoint::Utils,
|
2017-05-24 12:24:07 +02:00
|
|
|
apps::HOME_PAGE => SpecialEndpoint::Home,
|
2016-05-12 17:13:26 +02:00
|
|
|
_ => SpecialEndpoint::None,
|
|
|
|
}
|
2016-04-07 12:10:26 +02:00
|
|
|
}
|
|
|
|
|
2016-05-12 15:05:59 +02:00
|
|
|
match *url {
|
|
|
|
Some(ref url) => match url.host {
|
2017-05-24 12:24:07 +02:00
|
|
|
Host::Domain(ref domain) if domain.ends_with(dapps_domain) => {
|
|
|
|
let id = &domain[0..(domain.len() - dapps_domain.len())];
|
2017-02-04 09:52:14 +01:00
|
|
|
let (id, params) = if let Some(split) = id.rfind('.') {
|
|
|
|
let (params, id) = id.split_at(split);
|
|
|
|
(id[1..].to_owned(), [params.to_owned()].into_iter().chain(&url.path).cloned().collect())
|
|
|
|
} else {
|
|
|
|
(id.to_owned(), url.path.clone())
|
|
|
|
};
|
2016-05-12 15:05:59 +02:00
|
|
|
|
2016-05-12 17:13:26 +02:00
|
|
|
(Some(EndpointPath {
|
|
|
|
app_id: id,
|
2017-02-04 09:52:14 +01:00
|
|
|
app_params: params,
|
2016-05-12 17:13:26 +02:00
|
|
|
host: domain.clone(),
|
|
|
|
port: url.port,
|
2016-08-23 19:28:21 +02:00
|
|
|
using_dapps_domains: true,
|
2016-05-12 17:13:26 +02:00
|
|
|
}), special_endpoint(url))
|
2016-05-12 15:05:59 +02:00
|
|
|
},
|
|
|
|
_ if url.path.len() > 1 => {
|
2017-02-04 09:52:14 +01:00
|
|
|
let id = url.path[0].to_owned();
|
2016-05-12 17:13:26 +02:00
|
|
|
(Some(EndpointPath {
|
2017-02-04 09:52:14 +01:00
|
|
|
app_id: id,
|
|
|
|
app_params: url.path[1..].to_vec(),
|
2016-05-12 17:13:26 +02:00
|
|
|
host: format!("{}", url.host),
|
|
|
|
port: url.port,
|
2016-08-23 19:28:21 +02:00
|
|
|
using_dapps_domains: false,
|
2016-05-12 17:13:26 +02:00
|
|
|
}), special_endpoint(url))
|
2016-04-07 15:14:39 +02:00
|
|
|
},
|
2016-05-12 17:13:26 +02:00
|
|
|
_ => (None, special_endpoint(url)),
|
2016-05-12 15:05:59 +02:00
|
|
|
},
|
2016-05-12 17:13:26 +02:00
|
|
|
_ => (None, SpecialEndpoint::None)
|
2016-04-07 12:10:26 +02:00
|
|
|
}
|
|
|
|
}
|
2016-05-12 14:45:09 +02:00
|
|
|
|
2016-05-12 15:05:59 +02:00
|
|
|
#[test]
|
2016-05-12 17:13:26 +02:00
|
|
|
fn should_extract_endpoint() {
|
2017-05-24 12:24:07 +02:00
|
|
|
let dapps_domain = ".web3.site";
|
|
|
|
assert_eq!(extract_endpoint(&None, dapps_domain), (None, SpecialEndpoint::None));
|
2016-05-12 15:05:59 +02:00
|
|
|
|
|
|
|
// With path prefix
|
|
|
|
assert_eq!(
|
2017-05-24 12:24:07 +02:00
|
|
|
extract_endpoint(&Url::parse("http://localhost:8080/status/index.html").ok(), dapps_domain),
|
2016-05-12 17:13:26 +02:00
|
|
|
(Some(EndpointPath {
|
|
|
|
app_id: "status".to_owned(),
|
2017-02-04 09:52:14 +01:00
|
|
|
app_params: vec!["index.html".to_owned()],
|
2016-05-12 17:13:26 +02:00
|
|
|
host: "localhost".to_owned(),
|
|
|
|
port: 8080,
|
2016-08-23 19:28:21 +02:00
|
|
|
using_dapps_domains: false,
|
2016-05-12 17:13:26 +02:00
|
|
|
}), SpecialEndpoint::None)
|
|
|
|
);
|
2016-05-12 15:05:59 +02:00
|
|
|
|
|
|
|
// With path prefix
|
|
|
|
assert_eq!(
|
2017-05-24 12:24:07 +02:00
|
|
|
extract_endpoint(&Url::parse("http://localhost:8080/rpc/").ok(), dapps_domain),
|
2016-05-12 17:13:26 +02:00
|
|
|
(Some(EndpointPath {
|
|
|
|
app_id: "rpc".to_owned(),
|
2017-02-04 09:52:14 +01:00
|
|
|
app_params: vec!["".to_owned()],
|
2016-05-12 17:13:26 +02:00
|
|
|
host: "localhost".to_owned(),
|
|
|
|
port: 8080,
|
2016-08-23 19:28:21 +02:00
|
|
|
using_dapps_domains: false,
|
2016-05-12 17:13:26 +02:00
|
|
|
}), SpecialEndpoint::Rpc)
|
|
|
|
);
|
2016-05-12 15:05:59 +02:00
|
|
|
|
2016-05-13 18:40:20 +02:00
|
|
|
assert_eq!(
|
2017-05-24 12:24:07 +02:00
|
|
|
extract_endpoint(&Url::parse("http://my.status.web3.site/parity-utils/inject.js").ok(), dapps_domain),
|
2016-05-13 18:40:20 +02:00
|
|
|
(Some(EndpointPath {
|
2017-02-04 09:52:14 +01:00
|
|
|
app_id: "status".to_owned(),
|
|
|
|
app_params: vec!["my".to_owned(), "parity-utils".into(), "inject.js".into()],
|
|
|
|
host: "my.status.web3.site".to_owned(),
|
2016-05-13 18:40:20 +02:00
|
|
|
port: 80,
|
2016-08-23 19:28:21 +02:00
|
|
|
using_dapps_domains: true,
|
2016-05-13 18:40:20 +02:00
|
|
|
}), SpecialEndpoint::Utils)
|
|
|
|
);
|
|
|
|
|
2016-05-12 15:05:59 +02:00
|
|
|
// By Subdomain
|
|
|
|
assert_eq!(
|
2017-05-24 12:24:07 +02:00
|
|
|
extract_endpoint(&Url::parse("http://status.web3.site/test.html").ok(), dapps_domain),
|
2016-05-12 17:13:26 +02:00
|
|
|
(Some(EndpointPath {
|
2017-02-04 09:52:14 +01:00
|
|
|
app_id: "status".to_owned(),
|
|
|
|
app_params: vec!["test.html".to_owned()],
|
|
|
|
host: "status.web3.site".to_owned(),
|
2016-05-12 17:13:26 +02:00
|
|
|
port: 80,
|
2016-08-23 19:28:21 +02:00
|
|
|
using_dapps_domains: true,
|
2016-05-12 17:13:26 +02:00
|
|
|
}), SpecialEndpoint::None)
|
|
|
|
);
|
2016-05-12 15:05:59 +02:00
|
|
|
|
|
|
|
// RPC by subdomain
|
|
|
|
assert_eq!(
|
2017-05-24 12:24:07 +02:00
|
|
|
extract_endpoint(&Url::parse("http://my.status.web3.site/rpc/").ok(), dapps_domain),
|
2016-05-12 17:13:26 +02:00
|
|
|
(Some(EndpointPath {
|
2017-02-04 09:52:14 +01:00
|
|
|
app_id: "status".to_owned(),
|
|
|
|
app_params: vec!["my".to_owned(), "rpc".into(), "".into()],
|
|
|
|
host: "my.status.web3.site".to_owned(),
|
2016-05-12 17:13:26 +02:00
|
|
|
port: 80,
|
2016-08-23 19:28:21 +02:00
|
|
|
using_dapps_domains: true,
|
2016-05-12 17:13:26 +02:00
|
|
|
}), SpecialEndpoint::Rpc)
|
|
|
|
);
|
|
|
|
|
|
|
|
// API by subdomain
|
|
|
|
assert_eq!(
|
2017-05-24 12:24:07 +02:00
|
|
|
extract_endpoint(&Url::parse("http://my.status.web3.site/api/").ok(), dapps_domain),
|
2016-05-12 17:13:26 +02:00
|
|
|
(Some(EndpointPath {
|
2017-02-04 09:52:14 +01:00
|
|
|
app_id: "status".to_owned(),
|
|
|
|
app_params: vec!["my".to_owned(), "api".into(), "".into()],
|
|
|
|
host: "my.status.web3.site".to_owned(),
|
2016-05-12 17:13:26 +02:00
|
|
|
port: 80,
|
2016-08-23 19:28:21 +02:00
|
|
|
using_dapps_domains: true,
|
2016-05-12 17:13:26 +02:00
|
|
|
}), SpecialEndpoint::Api)
|
|
|
|
);
|
2016-05-12 14:45:09 +02:00
|
|
|
}
|