Abandoned. Don't use this and don't send pull requests.
PSR-7 compatible Middleware for league/route's RouteCollection.
composer require hannesvdvreken/route-middleware
This package aims to provide an easy to use middleware that takes PSR-7 Request object and converts it to a Response object by calling the Route's dispatcher class.
use League\Route\RouteCollection;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\RequestInterface;
$router = new RouteCollection();
// Setup router
$router->addRoute('GET', '/robots.txt', function (RequestInterface $request, ResponseInterface $response) {
// Adjust the response
return $response;
});
$app = new League\Route\Stack\Middleware($router);
$response = $app->handle($request);
Contributions are welcome. See the contributions file to know how to contribute.
The MIT License (MIT). Please see License File for more information.