PHP-Router icon indicating copy to clipboard operation
PHP-Router copied to clipboard

Added shouldDispatchCallback

Open lpotherat opened this issue 8 years ago • 0 comments

It is a very simple and naive implementation actually not PSR-15 compliant, but maybe it is a good start for PSR-15 compliance.

The idea is to set a callback before dispatching the route, with these rules :

  • The callback take one parameter which is the Route to be dispatched
  • if the callback returns false or equivalent, the route is ignored and the router continues to check other routes.
  • if the callback returns a route, it is dispatched. So you can simply return the route to allow it, or generate a new Route in replacement (like an Error route for example).

lpotherat avatar Jun 09 '17 11:06 lpotherat