Ignoring my routes?

Hello Guys,

I’m playing with routes for the first time this morning, trying to define a custom one.

addRoute(pattern=":service-key/status", handler=“Services”, action=“status”);

However, when I try and browse to http://localhost/some-service-key/status

I get an exception saying that The event: some-service-key.status is not valid registered event.

This would suggest to me that it’s using the default route of :handler/:action instead of matching my custom route.

Any suggestions? What am I doing wrong here?

Thanks chaps,

Robert

Can you please attach your Routes.cfm configuration file? Also, what version of ColdBox are you using?

Thanks.

-A

HI Aaron,

This is 3.0.0 RC2 from GitHub about a week ago.

My Routes.cfm looks like this: http://pastebin.com/bQRexdMn

Thanks,

Robert

Good news! The fix is simple:

ColdBox has a feature that allows you to qualify the variable to be of a specific type. Here is an example:
/test/:id-numeric

Once I changed your route from :service-key/status to “:service_key/status” everything worked as expected as ColdBox was no longer trying to confirm the type of the variable. This is probably a bug in ColdBox as I would expect it to only match “-numeric”.

To resolve, simply rename your variable to no longer have a dash ("-").

Aaron Greenlee
http://aarongreenlee.com/

Great stuff Aaron,

That makes perfect sense, i can see why that would be a problem :slight_smile:

When you say it allows you to specify a type, can that be any type? or does it only support numeric?

Thanks,

Robert

Good questions! This type validation is very powerful.

You can do simple evaluations such as “:foo-numeric/status” or “:foo-alpha/status”.

You can also perform custom validation using a regular expression such as “regex:{your regex here}/status”.

Cool stuff!

Ah, that is very cool.

I like that a lot.

Thanks for the help this Aaron, really appreciate it.

Robert

Also as a suggestion try to make the first part of a route static thy
way you have more permutations available.