Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add route defaults support #689

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Ratchet/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ public function __construct($httpHost = 'localhost', $port = 8080, $address = '1
* @param ComponentInterface $controller Your application to server for the route. If not specified, assumed to be for a WebSocket
* @param array $allowedOrigins An array of hosts allowed to connect (same host by default), ['*'] for any
* @param string $httpHost Override the $httpHost variable provided in the __construct
* @param array $defaulValues An array of default parameter values passed to symfony route config
* @return ComponentInterface|WsServer
*/
public function route($path, ComponentInterface $controller, array $allowedOrigins = array(), $httpHost = null) {
public function route($path, ComponentInterface $controller, array $allowedOrigins = array(), $httpHost = null,$defaulValues=array()) {
if ($controller instanceof HttpServerInterface || $controller instanceof WsServer) {
$decorated = $controller;
} elseif ($controller instanceof WampServerInterface) {
Expand Down Expand Up @@ -131,7 +132,9 @@ public function route($path, ComponentInterface $controller, array $allowedOrigi
}
}

$this->routes->add('rr-' . ++$this->_routeCounter, new Route($path, array('_controller' => $decorated), array('Origin' => $this->httpHost), array(), $httpHost, array(), array('GET')));
$defaulValues['_controller'] = $decorated;

$this->routes->add('rr-' . ++$this->_routeCounter, new Route($path, $defaulValues, array('Origin' => $this->httpHost), array(), $httpHost, array(), array('GET')));

return $decorated;
}
Expand Down