Analyzer::Cfml::Coldbox
Inherits Analyzer::Cfml::CfmlEngine < Analyzer < FileHelper < Reference < Object
ColdBox routing.
Routes are declared in a dedicated config/Router.cfc (or the legacy
config/routes.cfm), which makes them the closest CFML analogue of a
Rails or Laravel route file:
route( "/", "echo.index" );
post( "/login", "auth.login" );
get( "/sites/:slug/settings", "siteSettings.index" );
resources( resource = "authors", except = "new,edit" );
route( "/render/:format" ).to( "actionRendering.index" );
Two pieces of context live outside the router and are resolved here, because without them the emitted URLs and verbs are wrong:
- a module's routes are mounted under its
ModuleConfig.cfcentryPoint, so ContentBox's API routes are/cbapi/v1/loginrather than/login; - a bare
route()accepts any verb, but the handler constrains it viathis.allowedMethods, so that map decides the verbs instead of fanning out to all seven.
Constants
Legacy tag-syntax registration, still present in older configs.
this.allowedMethods = { index : "GET", create : "POST,PUT" }
route( "/x" ).withAction( { get : "show", post : "save" } ) binds
one action per verb, so the struct's keys are the verbs the route
answers. Without this a route() carrying only a withAction map
fell back to GET — ColdBox's own harness registers /invalid-restful
and /invalid-main-method as POST that way.
Chained builders that follow route( ... ) up to the statement end.
function show( event, rc, prc ) allowedMethods="GET"{
group( { pattern : "/api" }, function( options ){ ... } ) prefixes
every route declared inside the closure, and groups nest. Ignoring
them is both a false positive and a false negative at once: ColdBox's
own test harness declares route( "/:user_id" ) inside
group( { pattern : "/runAWNsync" ... } ), which was reported as
/:user_id — a URL that answers nothing — while the real
/runAWNsync/:user_id went unreported.
var sitePrefix = "/sites/:site" — referenced as #siteprefix#,
case-insensitively.
A group may name a namespace instead of a path. Namespaces are not paths in themselves: they become reachable only where a route mounts them, so the mount pattern is what supplies the prefix.
route( "/luis" ).toNamespaceRouting( "luis" ) — the mount pattern
and the namespace it carries, in one statement.
Placeholders carry inline constraints in three shapes, and all of
them must be stripped or the quantifier leaks into the URL:
:id-numeric{2} :name-regex(luis) :name{4}
The parameter is id / name; everything from the first -, {
or ( to the end of the segment is the constraint.
ColdBox's standard resource expansion.
route() is verb-agnostic; the rest name their verb.
Class methods
Instance methods
Instance-side view of the same declaration. The per-file rescues live on
this base class, which has no way to name the analyzer that is running
inside them, so a skipped file could not be attributed to a tech.
Deriving it from analyzer_for keeps the name written exactly once.