When using ColdBox's SES routing mechanisms you will come to a point where you would like to create variables depending on when a specific route matches or not. You can do so very easily by using the argument called matchVariables, which is a simple string of name-value pairs you want to create in the request collection (This was added in version 2.6.3). However, a hidden feature that we just documented that has been enabled since version 2.6.0, is that you can also pass named arguments to the addCourse() method and have them created on the request collection when the route matches. This makes it much much easier to create simple or complex variables than a simple string of name-value pairs.
Example using matchVariables:
That route will create the spaceUsed,foundAt
variables in the request collection when the route matches. However, let's see how easy it is to do it using by convention name-value pairs in the method.
I just added the foundAt,internalNamespace, and HashMap
variables just by adding them as virtual arguments. It gets even better if you are running Railo because you can use implicit Array/Structure notation to create very complex variables.
Again, this is now a documented feature in the wiki, so enjoy.