SES Route Optionals

Is there way to specify default values in a route if an optional is
not matched?

I'm working with a module and want to have the following route:

    routes = [
      {pattern=":handler?/:action?" }
    ];

If the handler or action is not found in the url I'd like to be able
to specify the default values for the route.

Right now it appears any explicit route arguments will always override
any pattern matches.

    routes = [
      {pattern=":handler?/:action?", handler="default", action="index" }
    ];

Will always force handler to equal default, and the action index
regardless of what the pattern is matching.

I am thinking a parameter matched in the pattern should take
precedence over the value specified in the arguments.

thoughts?

.brett

Basically if an optional is not matched it goes to the next route. is this the behavior?

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Well there should be some way to specify a default value for an
optional route parameter, so the route would match if an optional
parameter was matched or a default value for the parameter was
provided.

Ok, what about this.

if you do this: addRoute(pattern=“test/:var1?”, handler=“test”,action=“test”,var1=“defaultValue”);

Once the route matches and we convert the extra arguemnts into the requestion collection, in this case the var1 into rc.var1 = “defaultValue”, we will check if it already exists in the request collection. If it exists, we ignore meaning the incoming optional parameter came in, if not, we override it and have our default.

Will this work?

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

It should work, that is exactly what I was thinking. I'll let you
know if I run into any issues.

thanks,

.brett