Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge ca0f9d0 into 4f2dd36
Browse files Browse the repository at this point in the history
  • Loading branch information
michalbundyra committed Nov 15, 2017
2 parents 4f2dd36 + ca0f9d0 commit 0002aa9
Show file tree
Hide file tree
Showing 11 changed files with 202 additions and 145 deletions.
29 changes: 3 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,17 @@ env:
global:
- COMPOSER_ARGS="--no-interaction"
- COVERAGE_DEPS="satooshi/php-coveralls"
- LEGACY_DEPS="phpunit/phpunit"

matrix:
include:
- php: 5.6
env:
- DEPS=lowest
- php: 5.6
env:
- DEPS=locked
- TEST_COVERAGE=true
- php: 5.6
env:
- DEPS=latest
- php: 7
env:
- DEPS=lowest
- php: 7
env:
- DEPS=locked
- CS_CHECK=true
- php: 7
env:
- DEPS=latest
- php: 7.1
env:
- DEPS=lowest
- php: 7.1
env:
- DEPS=locked
- CS_CHECK=true
- TEST_COVERAGE=true
- php: 7.1
env:
- DEPS=latest
Expand All @@ -52,16 +33,12 @@ matrix:
- php: 7.2
env:
- DEPS=latest
allow_failures:
- php: 7.2

before_install:
- if [[ $TEST_COVERAGE != 'true' ]]; then phpenv config-rm xdebug.ini || return 0 ; fi
- travis_retry composer self-update

install:
- travis_retry composer install $COMPOSER_ARGS --ignore-platform-reqs
- if [[ $TRAVIS_PHP_VERSION =~ ^5.6 ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
- travis_retry composer install $COMPOSER_ARGS
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"sort-packages": true
},
"require": {
"php": "^5.6 || ^7.0",
"php": "^7.1",
"psr/container": "^1.0",
"psr/http-message": "^1.0.1",
"webimpress/http-middleware-compatibility": "^0.1.1",
"http-interop/http-server-middleware": "^1.0.1",
"zendframework/zend-expressive-router": "^2.2"
},
"require-dev": {
Expand Down
147 changes: 127 additions & 20 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 6 additions & 13 deletions src/BodyParams/BodyParamsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

namespace Zend\Expressive\Helper\BodyParams;

use Interop\Http\Server\MiddlewareInterface;
use Interop\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Webimpress\HttpMiddlewareCompatibility\HandlerInterface as DelegateInterface;
use Webimpress\HttpMiddlewareCompatibility\MiddlewareInterface;

use const Webimpress\HttpMiddlewareCompatibility\HANDLER_METHOD;

class BodyParamsMiddleware implements MiddlewareInterface
{
Expand Down Expand Up @@ -70,16 +68,11 @@ public function clearStrategies()
/**
* Process an incoming server request and return a response, optionally delegating
* to the next middleware component to create the response.
*
* @param ServerRequestInterface $request
* @param DelegateInterface $delegate
*
* @return ResponseInterface
*/
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
{
if (in_array($request->getMethod(), $this->nonBodyRequests)) {
return $delegate->{HANDLER_METHOD}($request);
return $handler->handle($request);
}

$header = $request->getHeaderLine('Content-Type');
Expand All @@ -89,10 +82,10 @@ public function process(ServerRequestInterface $request, DelegateInterface $dele
}

// Matched! Parse and pass on to the next
return $delegate->{HANDLER_METHOD}($strategy->parse($request));
return $handler->handle($strategy->parse($request));
}

// No match; continue
return $delegate->{HANDLER_METHOD}($request);
return $handler->handle($request);
}
}
13 changes: 6 additions & 7 deletions src/ContentLengthMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@

namespace Zend\Expressive\Helper;

use Interop\Http\Server\MiddlewareInterface;
use Interop\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Webimpress\HttpMiddlewareCompatibility\HandlerInterface as DelegateInterface;
use Webimpress\HttpMiddlewareCompatibility\MiddlewareInterface;

use const Webimpress\HttpMiddlewareCompatibility\HANDLER_METHOD;

/**
* Middleware to inject a Content-Length response header.
*
* If the response returned by a delegate does not contain a Content-Length
* If the response returned by a handler does not contain a Content-Length
* header, and the body size is non-null, this middleware will return a new
* response that contains a Content-Length header based on the body size.
*/
Expand All @@ -25,9 +24,9 @@ class ContentLengthMiddleware implements MiddlewareInterface
/**
* {@inheritDoc}
*/
public function process(ServerRequestInterface $request, DelegateInterface $delegate)
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
{
$response = $delegate->{HANDLER_METHOD}($request);
$response = $handler->handle($request);
if ($response->hasHeader('Content-Length')) {
return $response;
}
Expand Down

0 comments on commit 0002aa9

Please sign in to comment.