https://stackoverflow.com/questions/67190406/spring-boot-can-we-have-parts-of-request-mapping-as-optional-using-regex

All the details are mentioned in the stackoverflow question. If anything else is required, please let me know.

If this kind of functionality is supported by spring, please provide some examples for it.

Comment From: poutsma

The exact path pattern rules are given here: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/util/pattern/PathPattern.html

There are limitations to the path patterns we support, because we want to rule out ambiguities and make sure the algorithm is efficient.

It looks like you should be able to use the variable pattern {*foo} and get close to what you are looking for.

Comment From: rstoyanchev

@hiteshchopra please note that a link to SO is not a substitute for a self-sufficient description. Please see the guidelines.

Comment From: hiteshchopra

@poutsma, I have gone through the path patterns that are supported by spring and if what I want to achieve using regex is not possible then it's perfectly okay. I will use the {*foo} for it.

@rstoyanchev, thank you for pointing it out. It's my first time raising an issue here. Will keep the guidelines in mind from next time.