Skip to content

Commit 675c59f

Browse files
Fixed example because the "last" callable function does not receive the $next parameter
1 parent fe74b2e commit 675c59f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

examples/01-server-with-cors.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
$server = new Server([
1414
new CorsMiddleware(),
15-
function (ServerRequestInterface $request, callable $next) {
15+
function (ServerRequestInterface $request) {
1616
return new Response(200, ['Content-Type' => 'application/json'], json_encode([
1717
'some' => 'nice',
1818
'json' => 'values',
@@ -22,6 +22,10 @@ function (ServerRequestInterface $request, callable $next) {
2222

2323
$socket = new \React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0', $loop);
2424
$server->listen($socket);
25+
$server->on('error', function (Exception $exception) {
26+
echo get_class($exception) . ': ' . $exception->getMessage() . PHP_EOL;
27+
echo $exception->getTraceAsString() . PHP_EOL;
28+
});
2529

2630
echo 'Listening on ' . str_replace('tcp:', 'http:', $socket->getAddress()) . PHP_EOL;
2731

0 commit comments

Comments
 (0)