-
Notifications
You must be signed in to change notification settings - Fork 3.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
Make Route normalize HTTP method conditions #14908
Conversation
By normalizing the http method name to the correct case resource routes are a bit more ergonomic as case mistakes don't cause routes to fail matching. Fixes #14902
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.
Looks ok
Don't we have constants for request method types? |
Are you suggesting we validate the names instead of making them work? |
Normally I would say "yes", but in this particular case I guess we don't need to be too pedantic about the casing user uses. Though I was surprised to see strings being used for method types in our codebase too instead of constants. |
Well. it is bad that users can pass invalid methods. Forget casing, which is east to fix. What if they misspell "post"? |
That's why we should provide constants and let those using strings suffer their typos 😛. |
We could add constants, and validate that the methods are within the accepted range, but that is a different change that would need to go into 4.next. I would likely put the constants on RouteBuilder so that users wouldn't need to do additional imports if they already are using typehinting. |
Those constants already exist for user land code to be used by the way in Cake\Http\Client\Message:
etc |
Its a bit odd to need to import the HTTP client when defining routes though. |
Sure, just saying: if u wanted you could already use constants. |
I added a new |
The test failures are because signature of Is there any reason why |
Probably an accident/omission. |
Apparently all child methods of So I am going to keep the signatures as they are. |
Creating the array changes the behavior in ways that make the test suite sad.
By normalizing the http method name to the correct case resource routes are a bit more ergonomic as case mistakes don't cause routes to fail matching.
Fixes #14902