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 1 commit
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
15 changes: 14 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 @@ -88,8 +90,19 @@ public function group(string $prefix, callable $group): RouteGroup

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


/**
* @param ServerRequestInterface $request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{@inheritdoc}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this today for you so you can get your release out!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorted :-D

* @return ResponseInterface
*/
public function handle(ServerRequestInterface $request): ResponseInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd want this the other way round, handle to proxy to dispatch and won't be deprecating the dispatch method, router/dispatcher first with ability to run as a middleware second

{
if ($this->getStrategy() === null) {
$this->setStrategy(new ApplicationStrategy);
Expand Down