This commit is contained in:
Marcel Pociot 2018-11-20 17:47:15 +01:00
parent bf4df423b2
commit a12c3ba8d0
1 changed files with 35 additions and 8 deletions

View File

@ -30,17 +30,42 @@ class Router
throw InvalidWebSocketController::withController($action);
}
$this->addRoute($uri, $action);
$this->get($uri, $action);
}
public function addRoute($uri, $action)
public function get($uri, $action)
{
$this->routes->add($uri, $this->getRoute($uri, $action));
$this->addRoute('GET', $uri, $action);
}
protected function getRoute($uri, $action): Route
public function post($uri, $action)
{
return new Route($uri, ['_controller' => $this->wrapAction($action)], [], [], null, [], ['GET']);
$this->addRoute('POST', $uri, $action);
}
public function put($uri, $action)
{
$this->addRoute('PUT', $uri, $action);
}
public function patch($uri, $action)
{
$this->addRoute('PATCH', $uri, $action);
}
public function delete($uri, $action)
{
$this->addRoute('DELETE', $uri, $action);
}
public function addRoute($method, $uri, $action)
{
$this->routes->add($uri, $this->getRoute($method, $uri, $action));
}
protected function getRoute($method, $uri, $action): Route
{
return new Route($uri, ['_controller' => $this->wrapAction($action)], [], [], null, [], [$method]);
}
/**
@ -48,9 +73,11 @@ class Router
*/
public function echo()
{
//$this->addRoute('/', EchoWebsocketServer::class);
$this->addRoute('/apps/{appId}/status', LaravelEcho\Http\Controllers\StatusController::class);
//$this->addRoute('/apps/{appId}/channels', 'ChannelController@index');
//$this->get('/', EchoWebsocketServer::class);
$this->get('/apps/{appId}/status', LaravelEcho\Http\Controllers\StatusController::class);
$this->get('/apps/{appId}/channels', LaravelEcho\Http\Controllers\StatusController::class);
$this->get('/apps/{appId}/channels/{channelName}', LaravelEcho\Http\Controllers\StatusController::class);
$this->get('/apps/{appId}/channels/{channelName}/users', LaravelEcho\Http\Controllers\StatusController::class);
}
/**