RoutingMiddleware which implements the Psr MiddlewareInterface

1.0.0 2021-05-19 18:01 UTC

This package is auto-updated.

Last update: 2022-06-19 20:36:23 UTC


README

Tests

This repository holds the RoutingMiddleware which implements the Psr\Http\Server\MiddlewareInterface. It can be instantiated by create method which requires symfony RouteCollection, or it can be instantiated by constructor which requires the RequestMatcherInterface object.

Instalation

composer require pawel-jakowczyk/routing

Usage

use Laminas\Diactoros\ServerRequest;
use PJ\Routing\RoutingMiddleware;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Symfony\Component\Routing\RouteCollection;

$middleware = RoutingMiddleware::create(new RouteCollection());
$middleware->process(
    new ServerRequest(),
    new class() implements RequestHandlerInterface
    {
        public function handle(ServerRequestInterface $request): ResponseInterface
        {
            return new Response();
        }
    }
);