Skip to content

Commit d704df1

Browse files
author
Niels Theen
committed
Add example to use curly brackets
1 parent 05a5dd1 commit d704df1

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
require __DIR__ . '/../vendor/autoload.php';
4+
5+
$loop = \React\EventLoop\Factory::create();
6+
7+
$server = new \Legionth\React\Http\Rest\Server();
8+
9+
$server->get('/say/hello', function (\Psr\Http\Message\ServerRequestInterface $request, callable $next) {
10+
return new \React\Http\Response(200, array(), 'hello');
11+
});
12+
13+
$server->post('/say/{word}', function (\Psr\Http\Message\ServerRequestInterface $request, callable $next, array $arguments) {
14+
$word = $arguments['word'];
15+
16+
return new \React\Http\Response(200, array(), 'You said: ' . $word);
17+
});
18+
19+
$socket = new \React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0', $loop);
20+
21+
$server->listen($socket, null, new \Legionth\React\Http\Rest\Paramaters\Label\CurlyBrackets());
22+
23+
echo 'Listening on ' . str_replace('tcp:', 'http:', $socket->getAddress()) . PHP_EOL;
24+
25+
$loop->run();

0 commit comments

Comments
 (0)