Middleware proxy that executes a middleware based on request conditions.
The best way to install and use this package is with composer:
composer require northwoods/conditional-middlewareuse Northwoods\Middleware\ConditionalMiddleware;
/** @var \Psr\Http\Server\MiddlewareInterface */
$actual = /* any existing middleware */
$middleware = new ConditionalMiddleware($actual, function (Request $request): bool {
return $request->getHeaderLine('accept') === 'application/json';
});In this example, the wrapped $actual middleware will only be executed if the
request accepts the application/json content type.
The condition callable should use the following signature:
function (Request $request): bool;The condition must return true (by strict === comparison) for the wrapped
middleware to be executed. If the condition check fails the handler will be
called immediately.

