-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[RFC] [Routing] Allow multiple controllers per HTTP method #35973
Comments
Totally okay with this 👍 |
What's the proposal for this case?
|
My idea right now would be, if you are using multiple controllers you can't add |
Exception at compile-time seems like the best compromise to me |
-1 as it undermines the principle that a route is a combination of method, uri and defaults (e.g. controller). Also this creates discrepancies between yaml/xml and annotations. For annotation this is irrelevant but widens the differences in declarations in different formats. |
What if you want to have a controller for GET and another controller for both POST and PATCH? |
@stephanvierkant Well, instead of duplicating a whole route block, you'll duplicate one single controller name 😄 |
You still have this, methods are just moved under controller.
If I implement this, it would probably be both for xml and yaml, that would avoid discrepancies?
You can register same controller under different methods, no reason to not allow this. |
No, now one route definition maps to several real routes. And if you want to add other conditions to a certain method like expression, you have to revert back to the real route definition again becaues it's not supported in this new style. |
That is true, but my example was a simple one, and in a lot of my cases I don't need any additional conditions or configurations, but I still think this is a nice DX improvement and is worth it. |
Yes, and the same currently applies to localized routes, I don't see any issue with that. |
This is a good idea for methods. Would you also want to allow the same definition grouping for other values such as param requirements? eg for routing Either way it would be nice to be explicit in the syntax that this grouping works only with request methods or that it works with other request details too. |
I get your point and like the idea, maybe it would be a good additional feature if this one gets accepted, for now, I think as you said it would be enough to add test:
path: '/test'
controller:
- get: My\Action\TestGet
- post: My\Action\TestSave
- delete: My\Action\TestDelete
+ methods:
+ get: My\Action\TestGet
+ post: My\Action\TestSave
+ delete: My\Action\TestDelete |
The result of this would to have three real routes with different names? (e.g |
Well, if you are gonna set it like: test:
path: '/test'
controller:
methods:
get: My\Action\TestGet
post: My\Action\TestSave
delete: My\Action\TestDelete I would say that you are already using http verbs for methods? I don't see how generating a route I get your concern about |
The point is that we have control on the generated route name and it isn't necessarily related to http verbs when using multiples route definitions. That's my point. But I need to agree with you that for CRUD applications it could save time and is a concise way to group resource's controllers. My point is just on side effects by using this notation. |
@kunicmarko20 why did you close? You had pretty good overall feedback 🤔 |
Description
Instead of a need to write multiple route mappings for different method and controller combination, I would like to expand routing configuration to allow mapping multiple controllers per HTTP method.
Example
Before
After
The text was updated successfully, but these errors were encountered: