With ColdBox 3.0.0 you can use any kind of regular expression with your SES routes which makes it extremely flexible. One way to accomplish this is by using the constraints arguments when calling the addRoute() method to add a routing entry. So if I wanted to add a placeholder that matches a regex then I would do this:
addPattern(pattern="/api/:format/", constraints={format="(xml|json)"})
As you can see from the code above, the constraints argument is a structure in which the keys match a :placeholder in the pattern string. Then you start of the values with a parenthesis so the expression can be grouped and match and then I place my regex, which in my case is a simple xml or json value. However, you can get very funky and use your own regular expressions on ANY placeholder.
Add Your Comment