Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
legionth committed Feb 8, 2017
1 parent a59f72a commit a79af2a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This component builds on top of the `Socket` component to implement HTTP. Here
are the main concepts:

* **Server**: Attaches itself to an instance of
`React\Socket\ServerInterface`, parses any incoming data as HTTP, emits a
`request` event for each request.
`React\Socket\ServerInterface`, will use a callback function to receive request streams and
stream responses
* **Request**: A `ReadableStream` which streams the request body and contains
meta data which was parsed from the request header.
* **Response** A `WritableStream` which streams the response body. You can set
Expand All @@ -24,11 +24,12 @@ This is an HTTP server which responds with `Hello World` to every request.
$loop = React\EventLoop\Factory::create();
$socket = new React\Socket\Server($loop);

$http = new React\Http\Server($socket);
$http->on('request', function ($request, $response) {
$calllback = function (Request $request, Response $response) {
$response->writeHead(200, array('Content-Type' => 'text/plain'));
$response->end("Hello World!\n");
});
};

$http = new React\Http\Server($socket, $callback);

$socket->listen(1337);
$loop->run();
Expand Down

0 comments on commit a79af2a

Please sign in to comment.