Trailing slashes in routes support

This commit is contained in:
Alexander Pankratov 2020-01-13 17:50:56 +03:00
parent 8a74979cd7
commit 4a8057c0bf

View File

@ -46,10 +46,10 @@ class Server
{
$router = new Amp\Http\Server\Router();
foreach (['GET', 'POST'] as $method) {
$router->addRoute($method, '/api/{session}/{method}', ApiController::getRouterCallback($client));
$router->addRoute($method, '/api/{method}', ApiController::getRouterCallback($client));
$router->addRoute($method, '/events[/{session}]', EventsController::getRouterCallback($client));
$router->addRoute($method, '/api/{session}/{method}[/]', ApiController::getRouterCallback($client));
$router->addRoute($method, '/api/{method}[/]', ApiController::getRouterCallback($client));
$router->addRoute($method, '/events/{session}[/]', EventsController::getRouterCallback($client));
$router->addRoute($method, '/events[/]', EventsController::getRouterCallback($client));
}
$router->setFallback(new CallableRequestHandler(static function (Request $request) {