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
Custom Dispatcher Implementation for 3.x/4.x #2399
Comments
|
It works for me. I like @RyanNerd's pluralisation too. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As discussed on Slack, there are a few issues with the way
FastRoute\Dispatcher
returns information after a route has been dispatched.Issues
FastRoute\Dispatcher::dispatch()
returns an array with an inconsistent structureSolution
As discussed, I proposed that we implement our own dispatcher based on the logic found in
FastRoute\Dispatcher\GroupCountBased
. Our dispatcher would return aDispatcherResults
object which would have the following methods:::getStatus()
which would returnDispatcher::FOUND
,Dispatcher::NOT_ALLOWED
orDispatcher::NOT_FOUND
::getAllowedMethods()
which would return the allowed methods for dispatched route. This would be done dynamically as it has to loop through all the routes in order to compute the allowed methods. This is the exact reason why at the moment it is only done when theDispatcher::NOT_ALLOWED
status is being returned. This way, we offset the overhead on the end-user when they call this method.::getHandler()
when the route is found, this is the way we get the handler (callable) associated with the found route.Implementation
@akrabat mentioned that we could implement this in
3.x
and append theDispatcherResults
object generated to a request attributedispatcherResults
ordispatchResult
and consequently phase outrouteInfo
on4.x
which is currently being appended while routing is done.Questions
3.x
and phase outrouteInfo
in4.x
dispatchResult
ordispatcherResults
DispatcherResults
orDispatchResults
or something else.Status
The text was updated successfully, but these errors were encountered: