Allow convention routing to be disabled for base app router and module routers


Both the RoutingService and ModuleService add the /:handler/:action? route to the app router and module routers respectively if they don't exist. Put in a flag to the ColdBox CFC directives, or better yet, in the router DSL itself to disable the convention routing. Also, put a flag in the ModuleConfig, or better yet, the router DSL itself to disable it for a module as well.


Luis Majano
November 26, 2019, 2:56 PM

Can you expand on the reason for this?

Matthew Clemente
November 26, 2019, 2:57 PM

Just seconding this. I spent a good deal of time digging through the docs and code trying to determine why convention based routing was being applied while trying to limit access for a REST API to explicitly specified routes. Would really appreciate this flag.

If anyone else find this, on Slack Brad pointed out that you can add short circuit the convention by adding a "catch all" at the bottom of the router:

Luis Majano
November 26, 2019, 3:02 PM

So is this to disable routing completely for a module?

I need more reasons on why remove the conventions?

Matthew Clemente
November 26, 2019, 4:16 PM

In my use case, I wasn't trying to disable routing completely.

I was trying to build a REST API using ColdBox, structured using the rest-hmvc template. That is,

I only wanted handers/actions that I explicitly specified as routes to be accessible.

So, within the /v1 module if I add a handle method to my Echo.cfc handler, I don't necessarily want it automatically accessible via /api/v1/echo/handle.

For me it's about limiting and controlling the handler/actions that are exposed in my API.

The convention based routing is really powerful and convenient, but, I might not want it triggered everywhere, all the time, when the routing DSL itself is so powerful.

Perhaps could speak to more about why they short circuited the default convention during the REST API course.

As I said in Slack when I asked about this, I'm new to building REST APIs with ColdBox, so my understanding of how each component and setting interacts is limited, and there may be approaches that I'm missing.




Brad Wood