php-middleware/double-pass-compatibility

There is no license information available for the latest version (1.1.0) of this package.

Tools for support double pass middewares in PSR-15

1.1.0 2018-07-24 18:51 UTC

README

This package provide trait and abstract class for your psr-15 middlewares to double pass middewares support. So you can call your middleware in both styles.

Standard PSR-15 call:

$middleware->process($request, $delegate);

Possible call after implements this package:

$middleware($request, $response, $next);

Installation

composer require php-middleware/double-pass-compatibility

You can add trait into your middeware:

class Middleware implements MiddlewareInterface
{
    use PhpMiddleware\DoublePassCompatibilityTrait;

    public function process(ServerRequestInterface $request, DelegateInterface $delegate)
    {
       // Implementation and return response
    }
}

Or extend abstract class:

class Middleware extend AbstractDoublePassCompatibilityMiddleware implements MiddlewareInterface
{
    public function process(ServerRequestInterface $request, DelegateInterface $delegate)
    {
       // Implementation and return response
    }
}