-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Add support for using colon as a separator for custom methods #24771
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
Comments
The choice to append a custom HTTP method to the path does not seem like a good idea. It is very reminiscent of expressing acceptable content types via path extensions and see #24179 how that turned out. I see a lot of the same issues play out here as well. For example in a URL such as There is enough complexity in dealing with paths. I would strongly discourage overloading it with yet another concept. Have you considered passing the custom method as a query parameter? |
Thank you for your reply. I understand your concerns regarding supporting a specific requirement coming out of the specifications from a certain company into "general purpose" Spring Web frameworks. As one of my colleagues observed, maybe Google has more control over their APIs which allows them to have the colon character to mean something special. So, it only makes sense that we handle the weird edge cases resulting from the Google standard on our end as opposed to expecting everyone who uses Spring Web frameworks to treat colons a separator for custom methods. |
No worries, I'm not familiar enough with the Google API but indeed they can make many more assumptions about the URLs. Still I don't think it's a good idea to do it this way, and with sufficient numbers of users and use cases eventually the issues surface. |
Hey @deepak-auto , saw your comments and was curios, what's the alternative approach that you took to achieve this scalability in design? I wanted to use colons badly but Spring didn't help me either. |
Uh oh!
There was an error while loading. Please reload this page.
Affects: 5.1.7
Google's API Design Guide has the concept of a custom method which is identified by using the colon character
:
. The colon character is used to separate the custom verb from the resource.Spring-WebFlux currently treats colon as any other character. Although it is possible to create custom method endpoints using the version mentioned above, we run into weird errors such as:
GET /resources/{id}
andPOST /resources/{id}:customVerb
, and the user mistakenly sends a request toGET /resources/{id}:customVerb
, theGET /resources/{id}
endpoint gets hit instead of returning a 405 error@RequestMapping(path = "/resources")
on the controller and aPostMapping(path = ":customVerb"
on the method, it gets mapped toPOST /resources/:customVerb
instead ofPOST /resources:customVerb
. A workaround we have found for this was to stop using the@RequestMapping
annotation and instead put the full path in the custom method's mapping itself.So, it would be great if the the team at Spring could provide first class support to the colon character as a custom method separator.
Thanks!
The text was updated successfully, but these errors were encountered: