Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Router a RequestHandlerInterface #271

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
use InvalidArgumentException;
use League\Route\Middleware\{MiddlewareAwareInterface, MiddlewareAwareTrait};
use League\Route\Strategy\{ApplicationStrategy, StrategyAwareInterface, StrategyAwareTrait};
use Psr\Http\Server\RequestHandlerInterface;
use Psr\Http\Message\{ResponseInterface, ServerRequestInterface};

class Router extends RouteCollector implements
MiddlewareAwareInterface,
RouteCollectionInterface,
StrategyAwareInterface
StrategyAwareInterface,
RequestHandlerInterface
{
use MiddlewareAwareTrait;
use RouteCollectionTrait;
Expand Down Expand Up @@ -112,6 +114,15 @@ public function dispatch(ServerRequestInterface $request): ResponseInterface
return $dispatcher->dispatchRequest($request);
}


/**
* {@inheritdoc}
*/
public function handle(ServerRequestInterface $request): ResponseInterface
{
return $this->dispatch($request);
}

/**
* Prepare all routes, build name index and filter out none matching
* routes before being passed off to the parser.
Expand Down