Blog

Luis Majano

May 10, 2010

Spread the word


Share your thoughts

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

Recent Entries

Into the Box 2024 Last Early Bird Days!

Into the Box 2024 Last Early Bird Days!

Time is ticking, with less than 60 days remaining until the excitement of Into the Box 2024 unfolds! Don't let this golden opportunity slip away; our exclusive Early Bird Pricing is here for a limited time only, available until March 31st. Why wait? Secure your seat now and take advantage of this steal!

Maria Jose Herrera
Maria Jose Herrera
March 20, 2024
Ortus February Newsletter 2024

Ortus February Newsletter 2024

Welcome to Ortus Solutions’ monthly roundup, where we're thrilled to showcase cutting-edge advancements, product updates, and exciting events! Join us as we delve into the latest innovations shaping the future of technology.

Maria Jose Herrera
Maria Jose Herrera
March 06, 2024
Unveiling the Future of CFML Development - 3rd Round of Sessions

Unveiling the Future of CFML Development - 3rd Round of Sessions

Welcome back to our journey into the future of CFML development! As excitement continues to build for Into the Box 2024, we're thrilled to bring you the latest updates on what promises to be a transformative event. Continuing our blog post series, let's delve deeper into the third wave of session releases and discover the key surprises awaiting attendees. Learn More

Maria Jose Herrera
Maria Jose Herrera
March 01, 2024