Skip to content

Commit

Permalink
Adjust readme router syntax
Browse files Browse the repository at this point in the history
See #20
  • Loading branch information
samdark committed Feb 2, 2020
1 parent b166898 commit 99130fb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ use \Yiisoft\Router\Route;
$router = $container->get(Yiisoft\Router\UrlMatcherInterface::class);
$responseFactory = $container->get(\Psr\Http\Message\ResponseFactoryInterface::class);

$router->addRoute(Route::get('/test/{id:\w+}')->name('test')->to(function (ServerRequestInterface $request, RequestHandlerInterface $next) use ($responseFactory) {
$id = $request->getAttribute('id');
$router->addRoute(Route::get('/test/{id:\w+}', function (ServerRequestInterface $request, RequestHandlerInterface $next) use ($responseFactory) {
$id = $request->getAttribute('id');

$response = $responseFactory->createResponse();
$response->getBody()->write('You are at test with param ' . $id);
return $response;
}));
$response = $responseFactory->createResponse();
$response->getBody()->write('You are at test with param ' . $id);
return $response;
})->name('test'));
```

Then that is how URL could be obtained for it:
Expand Down

0 comments on commit 99130fb

Please sign in to comment.