PHP code example of northwoods / conditional-middleware

1. Go to this page and download the library: Download northwoods/conditional-middleware library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

northwoods / conditional-middleware example snippets


use 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';
});

function (Request $request): bool;