diff --git a/src/Ratchet/App.php b/src/Ratchet/App.php index c6d9ceb3..bf10c070 100644 --- a/src/Ratchet/App.php +++ b/src/Ratchet/App.php @@ -119,7 +119,20 @@ public function route($path, ComponentInterface $controller, array $allowedOrigi $decorated = new OriginCheck($decorated, $allowedOrigins); } - $this->routes->add('rr-' . ++$this->_routeCounter, new Route($path, array('_controller' => $decorated), array('Origin' => $this->httpHost), array(), $httpHost)); + $route = null; + if ($path instanceof Route) { + $route = $path; + $route->setDefault('_controller', $decorated); + $route->addRequirements(array('Origin' => $this->httpHost)); + $route->setHost($httpHost); + } else { + $route = new Route($path, array( + '_controller' => $decorated + ), array( + 'Origin' => $this->httpHost + ), array(), $httpHost); + } + $this->routes->add('rr-' . ++$this->_routeCounter, $route); return $decorated; } @@ -130,4 +143,4 @@ public function route($path, ComponentInterface $controller, array $allowedOrigi public function run() { $this->_server->run(); } -} \ No newline at end of file +}