[coldbox-3.8.1] Module route on root

Is it possible to define a route from within a module that is at the application root and not the module “entryPoint”. When I set the module entry point to “/” it broke my main application, but when I attempt to create a route in the module it is always relative to the module entry point. Am I going to have to intercept the request?

Can you show how you are declaring the routes. I think if you put them in the module config, they will automatically be added with the module route. However, you can probably get the interceptor service and do your own manual route additions that don’t include the module prefix. Note, you’d have to manually remove those on module unload if the module may be added/removed at run time.



ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

Ok, I will look into that. Right now I am adding routes in my ModuleConfig file using the “routes” variable in the configure method.

Ok. So I have tried a couple things but I can’t seem to define a root route that points to a module handler.

Essentially what I am trying to do is create a module which will handle requests to /robots.txt. It is not a core/essential part of our application so I want to encapsulate the functionality in a module. I figured out that I needed to setExtensionDetection(true) and setValidExtensions('txt') then I can make requests to either /robots or /robots.txt and it resolves. However when I try to route to my module with addRoute(pattern='/robots', module='robotsTxtModule', handler='Robots', action='txt') I get an exception, “Error importing routes configuration file: Module routes for robotsTxtModule do not exists Loaded module routes are…”. The only way I can make this error go away is to call addModuleRoutes(pattern="/some-pattern', module='robotsTxtModule'), but this means that route ends up being /some-pattern/robots. And I am back to square one.

I tried doing this both in the root Routes.cfm file and by getting the SES Interceptor from the InterceptorService via an onRequestCapture intercept in my module. Both have the same result (unsurprisingly).

Ultimately I want to do the same thing with a sitemap module.

It seems to me that a route is a route and should not care where it gets routed to, but the framework is essentially forcing a prefix on any route to a module. Am I missing something?