I’d like to create a restful service without having to define any specific routes for each “verb”.
I know that I can specify routes for the specific methods, but I think I saw an example somewhere where these were defined in the handlers and not in the routes file… can anyone point me to such an example?
If you generate a handler you will see some code at the top that allows you to put verb restrictions on handler methods. Ie. this.allowedMethod = {delete=‘POST,DELETE’, index=‘GET’}
If I may ask a dumb question but why are routes defined in the routes.cfm? It seems it would make more sense to define them in the handlers. Just curious…
Pretty much the decision to have them outside of your handler implementation is to have them decoupled from the handlers. Also, there is one routing table you can look at instead of tons of handler code. And also, you can create mutliple routes that point to the same handler methods instead of binding a handler method to only one route.
That’s pretty much why it is separate and not in the handler itself.