-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Dapp refresh #5752
Dapp refresh #5752
Changes from 4 commits
2d19a67
11f4fa5
1c80221
9adfdc0
8428b23
c0e0022
baa2846
ca573b8
83430c0
25e5168
98a3eee
3815c17
5004dd3
97ae381
09e7533
95a90ff
e7961b5
f0d162d
960731c
5a93a74
d3fbfb8
e5f4a90
bda230b
7c7bd00
00a84ba
9433c5c
706db10
c4e2c88
04bd4d9
0327eec
4b45b02
9242dc5
fea37ce
785bed3
faa4cc1
8c0123c
dddd303
64633ec
004c9d3
03a5eb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
//! URL Endpoint traits | ||
|
||
use std::sync::Arc; | ||
use parking_lot::RwLock; | ||
use std::collections::BTreeMap; | ||
|
||
use hyper::{self, server, net}; | ||
|
@@ -39,7 +40,7 @@ pub struct EndpointInfo { | |
pub icon_url: String, | ||
} | ||
|
||
pub type Endpoints = Arc<BTreeMap<String, Box<Endpoint>>>; | ||
pub type Endpoints = Arc<RwLock<BTreeMap<String, Box<Endpoint>>>>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the end goal is to push to the BTreeMap new dapp entries as a js developer adds. Currently you have to restart parity to get the new dapp. |
||
pub type Handler = server::Handler<net::HttpStream> + Send; | ||
|
||
pub trait Endpoint : Send + Sync { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,15 +60,17 @@ impl http::RequestMiddleware for Router { | |
let is_get_request = *req.method() == hyper::Method::Get; | ||
let is_head_request = *req.method() == hyper::Method::Head; | ||
|
||
info!(target: "dapps", "Routing request to {:?}. Details: {:?}", url, req); | ||
trace!(target: "dapps", "Routing request to {:?}. Details: {:?}", url, req); | ||
let endpoints = self.endpoints.as_ref().map(|endpoints| endpoints.read()); | ||
|
||
let control = control.clone(); | ||
debug!(target: "dapps", "Handling endpoint request: {:?}", endpoint); | ||
let handler: Option<Box<Handler>> = match (endpoint.0, endpoint.1, referer) { | ||
// Handle invalid web requests that we can recover from | ||
(ref path, SpecialEndpoint::None, Some((ref referer, ref referer_url))) | ||
if referer.app_id == apps::WEB_PATH | ||
&& self.endpoints.as_ref().map(|ep| ep.contains_key(apps::WEB_PATH)).unwrap_or(false) | ||
&& endpoints.as_ref().map(|ep| ep.contains_key(apps::WEB_PATH)).unwrap_or(false) | ||
&& !is_web_endpoint(path) | ||
=> | ||
{ | ||
|
@@ -87,9 +89,9 @@ impl http::RequestMiddleware for Router { | |
.map(|special| special.to_async_handler(path.clone().unwrap_or_default(), control)) | ||
}, | ||
// Then delegate to dapp | ||
(Some(ref path), _, _) if self.endpoints.as_ref().map(|ep| ep.contains_key(&path.app_id)).unwrap_or(false) => { | ||
(Some(ref path), _, _) if endpoints.as_ref().map(|ep| ep.contains_key(&path.app_id)).unwrap_or(false) => { | ||
trace!(target: "dapps", "Resolving to local/builtin dapp."); | ||
Some(self.endpoints | ||
Some(endpoints | ||
.as_ref() | ||
.expect("endpoints known to be set; qed") | ||
.get(&path.app_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems that refreshing on 404 is gone now, so it's only manual afaict. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RwLock
is re-export inutil
.