Fixing redirection. Adding tests

This commit is contained in:
Tomasz Drwięga
2016-08-30 16:05:18 +02:00
parent efc846bb3e
commit 76966ab2fc
9 changed files with 591 additions and 3 deletions

View File

@@ -83,7 +83,7 @@ impl<A: Authorization + 'static> server::Handler<HttpStream> for Router<A> {
(Some(ref path), _) if self.endpoints.contains_key(&path.app_id) => {
self.endpoints.get(&path.app_id).unwrap().to_handler(path.clone())
},
// Try to resolve and fetch dapp
// Try to resolve and fetch the dapp
(Some(ref path), _) if self.fetch.contains(&path.app_id) => {
let control = self.control.take().expect("on_request is called only once, thus control is always defined.");
self.fetch.to_handler(path.clone(), control)
@@ -93,6 +93,11 @@ impl<A: Authorization + 'static> server::Handler<HttpStream> for Router<A> {
let address = apps::redirection_address(path.using_dapps_domains, self.main_page);
Redirection::new(address.as_str())
},
// Redirect any GET request to home.
_ if *req.method() == hyper::method::Method::Get => {
let address = apps::redirection_address(false, self.main_page);
Redirection::new(address.as_str())
},
// RPC by default
_ => {
self.special.get(&SpecialEndpoint::Rpc).unwrap().to_handler(EndpointPath::default())