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

Separate routing from dispatching #2288

Merged
merged 4 commits into from
Aug 17, 2017
Merged

Separate routing from dispatching #2288

merged 4 commits into from
Aug 17, 2017

Conversation

akrabat
Copy link
Member

@akrabat akrabat commented Aug 13, 2017

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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 93.054% when pulling a170f2a on akrabat:separate-routing-from-rendering into ee32eb6 on slimphp:4.x.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 93.054% when pulling a170f2a on akrabat:separate-routing-from-rendering into ee32eb6 on slimphp:4.x.

Copy link
Member

@geggleto geggleto left a 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?

/**
* Perform routing and store matched route to the request's attributes
*/
class Routing
Copy link
Member

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.

Copy link
Member Author

@akrabat akrabat Aug 14, 2017

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.

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Renamed to RoutingMiddleware

* @param ServerRequestInterface $request PSR7 server request
* @return ServerRequestInterface
*/
public function doRouting(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.

.............. 👎 you can... doBetter

Copy link
Member

Choose a reason for hiding this comment

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

Whats wrong with this?

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

performRouting() ?

Copy link
Member

Choose a reason for hiding this comment

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

dispatchRequest ?

Copy link
Member Author

@akrabat akrabat Aug 15, 2017

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.

Copy link
Member

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?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 93.054% when pulling 68d4ba6 on akrabat:separate-routing-from-rendering into ee32eb6 on slimphp:4.x.

@akrabat
Copy link
Member Author

akrabat commented Aug 17, 2017

Rebased

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 93.054% when pulling eb71f27 on akrabat:separate-routing-from-rendering into a60a712 on slimphp:4.x.

@akrabat
Copy link
Member Author

akrabat commented Aug 17, 2017

Renamed doRouting() to performRouting()

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 93.054% when pulling 058d684 on akrabat:separate-routing-from-rendering into a60a712 on slimphp:4.x.

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.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 93.035% when pulling 7ff1c47 on akrabat:separate-routing-from-rendering into 2cac1ac on slimphp:4.x.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 93.035% when pulling 0c3eb5d on akrabat:separate-routing-from-rendering into 2cac1ac on slimphp:4.x.

@akrabat akrabat merged commit 0c3eb5d into slimphp:4.x Aug 17, 2017
@akrabat akrabat added this to the 4.0 milestone Nov 26, 2017
@akrabat akrabat deleted the separate-routing-from-rendering branch April 18, 2019 06:07
@l0gicgate l0gicgate mentioned this pull request Apr 25, 2019
@l0gicgate l0gicgate mentioned this pull request Aug 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants