I would say yes, put in a ticket. In the mean time, you could create a loop to create routes for all your handlers if there’s a lot.
https://ortussolutions.atlassian.net/browse/COLDBOX-181
It’s not that there’s a lot. It’s just I don’t want to expose a path externally. Case in point, I might have this directory structure: /handlers/api/v1/{{ cfc file }} and I just want to point the /api/:handler/:action to that path/package without having to declare every single handler in the v1 directory structure.
Well, if you only have a few handlers, the workaround would be to just create a route like so for each handler (replacing {{ cfc file }} with each file name).
addRoute(pattern=“api/{{ cfc file]]/:action”,handler=“api/v1/{{ cfc file]]”);
Then your v1 folder is invisible to the public. The look was just to save you some typing.
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com
Yes, I’m aware. Ultimately, the ticket I opened is a feature I’d like to have for addRoute() ( both for a personal project and at work ).
Technically you could do this with the new “condition” closure. That allows you to attach a conditional closure to the pattern. It also receives the matched request string as an argument. So you can detect there your conditions for approving the match.
Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
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
Where do I find documentation on this?
Google search points me to - https://ortussolutions.atlassian.net/browse/COLDBOX-165
addRoute(pattern=“api/:handler/:action”,viewNoLayout=“true”,path=“Only.Look.In.This.Path.For.API.Handlers”, condition="udf or closure);
It’s brand new and unreleased right now on the dev branch. We’re still getting it added in the docs, but here’s the what’s new page we’ve started for the 3.7 release and there’s an example in there I believe.
http://wiki.coldbox.org/wiki/WhatsNew:3.7.0.cfm
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com
Okay, then none of this meets my current needs. So I guess I wait.
Is won’t work for you Todd?
I’m running 3.6 final, not the development branch.
OK, I Get what you want to do now. However, have you looked at the constraints?
addPattern(pattern="/api/:handler", constraints={
handler = “(my regex here)”
});
This way you can limit the handler via the pattern. Have you tried that?
Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
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
I tried:
addRoute(pattern=“api/:handler/:action”,viewNoLayout=true, constraints={ handler = “(v1/[^/]+?)”});
Error Type: HandlerService.EventHandlerNotRegisteredException : [N/A]
Error Messages: The event: api.roles.test is not valid registered event.
I also tried:
addRoute(pattern=“api/:handler/:action”,viewNoLayout=true, constraints={ handler = “v1/([^/.]+?)”});
Same result. No go.
Sorry Todd, busy weekend baby sitting. Will try things out this week
Luis F. Majano
CEO
Ortus Solutions, Corp
www.ortussolutions.com
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
Social: twitter.com/lmajano facebook.com/lmajano
Todd, I’ve never used the constraints, but I don’t see how they would help you reach your end. They appear to simply limit the handlers that a route applies to, but I don’t they they are capable of dynamically adding a package into the matched :handler in the URL.
Thanks!
~Brad
ColdBox Platform Evangelist
Ortus Solutions, Corp
E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com
oh Brad,
The problem wasn’t a problem, well it was only to me I thought I was loading a transient, and it was why I was seeing the behavior I was seeing. That’s what you get when writing a QAD test and having a typo in your test.
Lol
I’m only doing what Luis suggested.