Skip to content

Commit

Permalink
Merge pull request #27 from basz/fix/http-middleware-compatibility
Browse files Browse the repository at this point in the history
Fix/http middleware compatibility
  • Loading branch information
basz authored Oct 28, 2017
2 parents 8b644d2 + 49db9d3 commit 0a3c984
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
21 changes: 14 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,26 @@
{
"name": "Paul M Jones",
"email": "[email protected]"
},
{
"name": "Bas Kamer",
"email": "[email protected]"
}
],
"config": {
"sort-packages": true
},
"require": {
"php":"^5.6 || ^7.0",
"psr/http-message":"^1.0",
"http-interop/http-factory":"^0.3",
"http-interop/http-middleware": "^0.5",
"php": "^5.6 || ^7.0",
"http-interop/http-factory": "^0.3",
"psr/http-message": "^1.0",
"webimpress/http-middleware-compatibility": "^0.1.4"
},
"require-dev": {
"phpunit/phpunit": "5.7",
"http-interop/http-factory-diactoros":"^0.3",
"aura/di": "^3.0"
"aura/di": "^3.0",
"http-interop/http-factory-diactoros": "^0.3",
"http-interop/http-middleware": "^0.5",
"phpunit/phpunit": "5.7"
},
"suggest": {
"http-interop/http-factory-diactoros": "Use zend framework zend-diactoros as the psr7 implementaion",
Expand Down
12 changes: 7 additions & 5 deletions src/AssetAction.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

namespace Hkt\Psr7Asset;

use Psr\Http\Message\ServerRequestInterface;
use Interop\Http\Server\MiddlewareInterface;
use Interop\Http\Server\RequestHandlerInterface;
use Webimpress\HttpMiddlewareCompatibility\HandlerInterface;
use Webimpress\HttpMiddlewareCompatibility\MiddlewareInterface;
use const Webimpress\HttpMiddlewareCompatibility\HANDLER_METHOD;

/**
*
Expand Down Expand Up @@ -64,12 +66,12 @@ public function __construct(
*
* @param ServerRequestInterface $request
*
* @param RequestHandlerInterface $delegate
* @param HandlerInterface $handler
*
* @return ResponseInterface
*
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler)
public function process(ServerRequestInterface $request, HandlerInterface $handler)
{
$route = $this->router->match($request);

Expand All @@ -83,6 +85,6 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
}
}

return $handler->handle($request);
return $handler->{HANDLER_METHOD}($request);
}
}
4 changes: 1 addition & 3 deletions tests/src/AssetActionTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?php
namespace Hkt\Psr7Asset;

use Hkt\Psr7Asset\AssetResponder;
use Http\Factory\Diactoros\ResponseFactory;
use Psr\Http\Message\ResponseInterface;
use Zend\Diactoros\Response;
use Zend\Diactoros\ServerRequestFactory;
use Http\Factory\Diactoros\ResponseFactory;

class AssetActionTest extends \PHPUnit_Framework_TestCase
{
Expand Down
7 changes: 5 additions & 2 deletions tests/src/RequestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

namespace Hkt\Psr7Asset;

use Interop\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Webimpress\HttpMiddlewareCompatibility\HandlerInterface;
use Zend\Diactoros\Response;

class RequestHandler implements RequestHandlerInterface
/**
* Class RequestHandler from http-interop/http-middleware:^0.5
*/
class RequestHandler implements HandlerInterface
{
public function handle(ServerRequestInterface $request)
{
Expand Down

0 comments on commit 0a3c984

Please sign in to comment.