-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Separate routing from dispatching #2288
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also will this not only affect Slim currently when you use the invoke method. We would need to make more changes to affect run?
Slim/Middleware/Routing.php
Outdated
/** | ||
* Perform routing and store matched route to the request's attributes | ||
*/ | ||
class Routing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a new name for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any preference? RoutingMiddleware
?
Though if we postfix with Middleware
, we'll have to change the other Middleware classes too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to have everything suffixed ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to RoutingMiddleware
Slim/Middleware/Routing.php
Outdated
* @param ServerRequestInterface $request PSR7 server request | ||
* @return ServerRequestInterface | ||
*/ | ||
public function doRouting(ServerRequestInterface $request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.............. 👎 you can... doBetter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whats wrong with this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doRouting ... surely we can come up with a better name :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
performRouting()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dispatchRequest
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't be dispatchRequest
as this code doesn't dispatch - it only performs the routing work and then we dispatch later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe prepare
or perform
then?
Rebased |
Renamed |
Move the routing to middleware so that the user can add it wherever they want it to be within the middleware stack. This gives us the new capability to allow for some middleware to run before routing and some after. If the `Routing` middleware isn't added by the user, then automatically call it in `App::__invoke()` as a last resort. Also, remove `determineRouteBeforeAppMiddleware` setting as it's no longer necessary.
Also update comment to be clearer.
Move the routing to middleware so that the user can add it wherever they want it to be within the middleware stack. This gives us the new capability to allow for some middleware to run before routing and some after.
If the
Routing
middleware isn't added by the user, then automatically call it inApp::__invoke()
as a last resort.Also, remove
determineRouteBeforeAppMiddleware
setting as it's no longer necessary.