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

Question/Poll: Should we bump to v3 for per route and per group middleware? #113

Closed
philipobenito opened this issue Apr 1, 2016 · 13 comments · Fixed by #115
Closed

Question/Poll: Should we bump to v3 for per route and per group middleware? #113

philipobenito opened this issue Apr 1, 2016 · 13 comments · Fixed by #115

Comments

@philipobenito
Copy link
Member

So, I've been looking at bringing in a PSR-7 middleware implementation, the front runner is Relay at the moment. With version two though I feel I've made a glaring mistake with the JsonStrategy in not passing the response object off to the controller.

What I'd like to do is bump to version 3 and implement in a way that I'd be happy with, allowing per route and per group middleware on any strategy. As things stand, because of the issue with the JsonStrategy I would probably have to provide a new middleware specific strategy to keep BC.

I suppose one of the benefits of bumping to v3 now is that the install base for v2 is still quite small so support would only have to be provided for a small amount of time rather than waiting and having to support it for much longer, and it would be a relatively simply upgrade guide.

Thoughts? @hannesvdvreken @localheinz @kayladnls

@hannesvdvreken
Copy link
Contributor

Is it perhaps possible to make a different strategy and deprecate the old one? Then you'd be fine with a new minor.

I'm OK with a v3 as well, though.

@hannesvdvreken
Copy link
Contributor

If it's a small change, could you provide a branch to showcase the changes and discuss further based on that?

@philipobenito
Copy link
Member Author

The discussion is going to dictate where I go with the code.

The breaking change would be here https://github.com/thephpleague/route/blob/master/src/Strategy/JsonStrategy.php#L19 where I would be adding the response object as the second parameter on this call.

@hannesvdvreken
Copy link
Contributor

That's it? Then I'd lean more towards my first proposal: deprecate JsonStrategy, and make a new JsonResponseStrategy, tag 2.1.0 and be done with it.

@philipobenito
Copy link
Member Author

And just have the original strategy ignore the new middleware functionality?

@hannesvdvreken
Copy link
Contributor

Maybe, does that seem plausible to you?

@philipobenito
Copy link
Member Author

Yeah, I think that works for me.

RequestResponseStrategy & JsonResponseStrategy - can add middleware and will invoke them.

JsonStrategy & ParamStrategy - throw exception when dispatching on this strategy and a middleware is found?

JsonStrategy - deprecated and will be removed in version 3.0.0?

@philipobenito
Copy link
Member Author

Maybe actually have it as JsonRequestResponseStrategy, that way all strategies going forward that are suffixed RequestResponseStrategy can be used with middleware and we don't necessarily need to deprecate the JsonStrategy?

That way we can continue to introduce strategies and it has a format. As in SomeStrangeFormatRequestResponseStrategy etc down the line.

@hannesvdvreken
Copy link
Contributor

Deprecating JsonStrategy isn't necessary, no. But you'd want that to avoid confusion why there are 2 json related strategy classes, and if you want to remove it in v3.

@philipobenito
Copy link
Member Author

Well there would be value in keeping both, the difference would just have to be explained thoroughly.

JsonRequestResponseStrategy you would be expected to manipulate the response and return it.

JsonStrategy would attempt to build a response from what you return (array, json string etc).

@CMCDragonkai
Copy link

Route 2.x is not compatible with things like League\Relay right?

@hannesvdvreken
Copy link
Contributor

hannesvdvreken commented Mar 3, 2017

@CMCDragonkai I guess you meant https://github.com/relayphp/Relay.Relay ? League\Relay doesn't exist, afaik.

if you have a League\Route\RouteCollection object, you can use [$routeCollection, 'dispatch'] (which is a PHP callable) to pass to Relay as a middleware.

@CMCDragonkai
Copy link

Yes that's what I meant. Oh that's nice. Hopefully this can be clearer in the docs.

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

Successfully merging a pull request may close this issue.

3 participants