-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from legionth/server-params
Add server-side parameters to request object
- Loading branch information
Showing
12 changed files
with
253 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
use React\EventLoop\Factory; | ||
use React\Socket\Server; | ||
use React\Http\Response; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
$loop = Factory::create(); | ||
$socket = new Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0', $loop); | ||
|
||
$server = new \React\Http\Server($socket, function (ServerRequestInterface $request) { | ||
$body = "Your IP is: " . $request->getServerParams()['REMOTE_ADDR']; | ||
|
||
return new Response( | ||
200, | ||
array('Content-Type' => 'text/plain'), | ||
$body | ||
); | ||
}); | ||
|
||
echo 'Listening on http://' . $socket->getAddress() . PHP_EOL; | ||
|
||
$loop->run(); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters