Skip to content

Commit

Permalink
Merge pull request #9 from sandrokeil/feature/use-react-http-1.0.0
Browse files Browse the repository at this point in the history
Use react http 1.0
  • Loading branch information
christoph-kluge authored Sep 19, 2020
2 parents d61eb96 + e3d5825 commit d6ecd5c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
"require": {
"php": ">=5.6.0",
"psr/http-message": "^1.0",
"react/http": "^1.0.0",
"react/promise": "^2.5",
"neomerx/cors-psr7": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.10||^5.0",
"react/http": "^0.8.6",
"ringcentral/psr7": "^1.2"
},
"scripts": {
Expand Down
9 changes: 5 additions & 4 deletions examples/01-server-with-cors.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@

use Psr\Http\Message\ServerRequestInterface;
use React\EventLoop\Factory;
use React\Http\Response;
use React\Http\Message\Response;
use React\Http\Server;
use Sikei\React\Http\Middleware\CorsMiddleware;

require __DIR__ . '/../vendor/autoload.php';

$loop = Factory::create();

$server = new Server([
$server = new Server(
$loop,
new CorsMiddleware(),
function (ServerRequestInterface $request) {
return new Response(200, ['Content-Type' => 'application/json'], json_encode([
'some' => 'nice',
'json' => 'values',
]));
},
]);
}
);

$socket = new \React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:0', $loop);
$server->listen($socket);
Expand Down
9 changes: 5 additions & 4 deletions examples/02-server-with-cors-strict-checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,24 @@

use Psr\Http\Message\ServerRequestInterface;
use React\EventLoop\Factory;
use React\Http\Response;
use React\Http\Message\Response;
use React\Http\Server;
use Sikei\React\Http\Middleware\CorsMiddleware;

require __DIR__ . '/../vendor/autoload.php';

$loop = Factory::create();

$server = new Server([
$server = new Server(
$loop,
new CorsMiddleware(['server_url' => 'http://api.example.net:8080']),
function (ServerRequestInterface $request) {
return new Response(200, ['Content-Type' => 'application/json'], json_encode([
'some' => 'nice',
'json' => 'values',
]));
},
]);
}
);

$socket = new \React\Socket\Server(isset($argv[1]) ? $argv[1] : '0.0.0.0:8080', $loop);
$server->listen($socket);
Expand Down
2 changes: 1 addition & 1 deletion src/CorsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Neomerx\Cors\Contracts\AnalyzerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use React\Http\Response;
use React\Http\Message\Response;
use function React\Promise\resolve;
use Sikei\React\Http\Middleware\CorsMiddlewareAnalysisStrategy as Strategy;
use Sikei\React\Http\Middleware\CorsMiddlewareConfiguration as Config;
Expand Down
4 changes: 2 additions & 2 deletions tests/CorsMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use Neomerx\Cors\Contracts\Http\ParsedUrlInterface;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ServerRequestInterface;
use React\Http\Response;
use React\Http\Io\ServerRequest;
use React\Http\Message\Response;
use React\Http\Message\ServerRequest;
use React\Promise\Promise;
use React\Promise\PromiseInterface;

Expand Down

0 comments on commit d6ecd5c

Please sign in to comment.