Skip to content

php-middleware/double-pass-compatibility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

double-pass-compatibility Build Status

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
    }
}