Skip to content
This repository has been archived by the owner on Dec 6, 2022. It is now read-only.

Added shouldDispatchCallback #121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

lpotherat
Copy link
Contributor

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).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants