Merge with master

This commit is contained in:
Robert Habermeier
2016-06-29 14:46:29 +02:00
parent 3850ee64bb
commit 49024a4f28
235 changed files with 36456 additions and 4814 deletions

View File

@@ -1,7 +1,7 @@
[package]
description = "Parity Dapps crate"
name = "ethcore-dapps"
version = "1.2.0"
version = "1.3.0"
license = "GPL-3.0"
authors = ["Ethcore <admin@ethcore.io"]
build = "build.rs"
@@ -28,7 +28,7 @@ parity-dapps-wallet = { git = "https://github.com/ethcore/parity-dapps-wallet-rs
parity-dapps-dao = { git = "https://github.com/ethcore/parity-dapps-dao-rs.git", version = "0.4.0", optional = true }
parity-dapps-makerotc = { git = "https://github.com/ethcore/parity-dapps-makerotc-rs.git", version = "0.3.0", optional = true }
mime_guess = { version = "1.6.1" }
clippy = { version = "0.0.76", optional = true}
clippy = { version = "0.0.77", optional = true}
[build-dependencies]
serde_codegen = { version = "0.7.0", optional = true }
@@ -36,6 +36,6 @@ syntex = "*"
[features]
default = ["serde_codegen", "extra-dapps"]
extra-dapps = ["parity-dapps-wallet", "parity-dapps-dao", "parity-dapps-makerotc"]
extra-dapps = ["parity-dapps-wallet"]
nightly = ["serde_macros"]
dev = ["clippy", "ethcore-rpc/dev", "ethcore-util/dev"]

View File

@@ -42,11 +42,11 @@ pub struct EndpointInfo {
pub trait Endpoint : Send + Sync {
fn info(&self) -> Option<&EndpointInfo> { None }
fn to_handler(&self, path: EndpointPath) -> Box<server::Handler<HttpStream>>;
fn to_handler(&self, path: EndpointPath) -> Box<server::Handler<HttpStream> + Send>;
}
pub type Endpoints = BTreeMap<String, Box<Endpoint>>;
pub type Handler = server::Handler<HttpStream>;
pub type Handler = server::Handler<HttpStream> + Send;
pub struct ContentHandler {
content: String,
@@ -65,7 +65,7 @@ impl ContentHandler {
}
impl server::Handler<HttpStream> for ContentHandler {
fn on_request(&mut self, _request: server::Request) -> Next {
fn on_request(&mut self, _request: server::Request<HttpStream>) -> Next {
Next::write()
}

View File

@@ -132,9 +132,16 @@ impl Server {
special.clone(),
authorization.clone(),
))
.map(|l| Server {
server: Some(l),
panic_handler: panic_handler,
.map(|(l, srv)| {
::std::thread::spawn(move || {
srv.run();
});
Server {
server: Some(l),
panic_handler: panic_handler,
}
})
.map_err(ServerError::from)
}

View File

@@ -86,7 +86,7 @@ impl<T: Dapp> PageHandler<T> {
}
impl<T: Dapp> server::Handler<HttpStream> for PageHandler<T> {
fn on_request(&mut self, req: server::Request) -> Next {
fn on_request(&mut self, req: server::Request<HttpStream>) -> Next {
self.file = match *req.uri() {
RequestUri::AbsolutePath(ref path) => {
self.app.file(&self.extract_path(path))

View File

@@ -27,13 +27,13 @@ pub enum Authorized {
/// Authorization was successful.
Yes,
/// Unsuccessful authorization. Handler for further work is returned.
No(Box<server::Handler<HttpStream>>),
No(Box<server::Handler<HttpStream> + Send>),
}
/// Authorization interface
pub trait Authorization : Send + Sync {
/// Checks if authorization is valid.
fn is_authorized(&self, req: &server::Request)-> Authorized;
fn is_authorized(&self, req: &server::Request<HttpStream>)-> Authorized;
}
/// HTTP Basic Authorization handler
@@ -45,13 +45,13 @@ pub struct HttpBasicAuth {
pub struct NoAuth;
impl Authorization for NoAuth {
fn is_authorized(&self, _req: &server::Request)-> Authorized {
fn is_authorized(&self, _req: &server::Request<HttpStream>)-> Authorized {
Authorized::Yes
}
}
impl Authorization for HttpBasicAuth {
fn is_authorized(&self, req: &server::Request) -> Authorized {
fn is_authorized(&self, req: &server::Request<HttpStream>) -> Authorized {
let auth = self.check_auth(&req);
match auth {
@@ -89,7 +89,7 @@ impl HttpBasicAuth {
self.users.get(&username.to_owned()).map_or(false, |pass| pass == password)
}
fn check_auth(&self, req: &server::Request) -> Access {
fn check_auth(&self, req: &server::Request<HttpStream>) -> Access {
match req.headers().get::<header::Authorization<header::Basic>>() {
Some(&header::Authorization(
header::Basic { ref username, password: Some(ref password) }
@@ -105,7 +105,7 @@ pub struct UnauthorizedHandler {
}
impl server::Handler<HttpStream> for UnauthorizedHandler {
fn on_request(&mut self, _request: server::Request) -> Next {
fn on_request(&mut self, _request: server::Request<HttpStream>) -> Next {
Next::write()
}
@@ -141,7 +141,7 @@ impl server::Handler<HttpStream> for UnauthorizedHandler {
pub struct AuthRequiredHandler;
impl server::Handler<HttpStream> for AuthRequiredHandler {
fn on_request(&mut self, _request: server::Request) -> Next {
fn on_request(&mut self, _request: server::Request<HttpStream>) -> Next {
Next::write()
}

View File

@@ -49,12 +49,12 @@ pub struct Router<A: Authorization + 'static> {
endpoints: Arc<Endpoints>,
special: Arc<HashMap<SpecialEndpoint, Box<Endpoint>>>,
authorization: Arc<A>,
handler: Box<server::Handler<HttpStream>>,
handler: Box<server::Handler<HttpStream> + Send>,
}
impl<A: Authorization + 'static> server::Handler<HttpStream> for Router<A> {
fn on_request(&mut self, req: server::Request) -> Next {
fn on_request(&mut self, req: server::Request<HttpStream>) -> Next {
// Check authorization
let auth = self.authorization.is_authorized(&req);
@@ -124,7 +124,7 @@ impl<A: Authorization> Router<A> {
}
}
fn extract_url(req: &server::Request) -> Option<Url> {
fn extract_url(req: &server::Request<HttpStream>) -> Option<Url> {
match *req.uri() {
uri::RequestUri::AbsoluteUri(ref url) => {
match Url::from_generic_url(url.clone()) {

View File

@@ -33,7 +33,7 @@ impl Redirection {
}
impl server::Handler<HttpStream> for Redirection {
fn on_request(&mut self, _request: server::Request) -> Next {
fn on_request(&mut self, _request: server::Request<HttpStream>) -> Next {
Next::write()
}