Routing DSL
The ColdBox Routing DSL will be used to register routes for your application, which exists in your application or module router object. Routing takes place using several methods inside the router, which are divided into the following 3 categories:
Initiators - Starts a URL pattern registration, but does not fully register the route until a terminator is called (target).
Modifiers - Modifies the pattern with extra metdata to listen to from the incoming request.
Terminators - Finalizes the registration process usually by telling the router what happens when the route pattern is detected. This is refered to as the target.
Please note that order of declaration of the routes is imperative. Order matters.
Please remember to check out the latest API Docs for the latest methods and argument signatures.
Initiators
The following methods are used to initiate a route registration process.
Please note that a route will not register unless a terminator is called or the inline target terminator is passed.
route( pattern, [target], [name] )
- Register a new route with optional target terminators and a nameget( pattern, [target], [name] )
- Register a new route with optional target terminators, a name and a GET http verb restrictionpost( pattern, [target], [name] )
- Register a new route with optional target terminators, a name and a POST http verb restrictionput( pattern, [target], [name] )
- Register a new route with optional target terminators, a name and a PUT http verb restrictionpatch( pattern, [target], [name] )
- Register a new route with optional target terminators, a name and a PATCH http verb restrictionoptions( pattern, [target], [name] )
- Register a new route with optional target terminators, a name and a OPTIONS http verb restrictiongroup( struct options, body )
- Group routes together with options that will be applied to all routes declared in thebody
closure/lambda.
Modifiers
Modifiers will tell the routing service about certain restrictions, conditions or locations for the routing process. It will not register the route just yet.
header( name, value, overwrite=true )
- attach a response header if the route matchesheaders( map, overwrite=true )
- attach multiple response headers if the route matchesas( name )
- Register the route as a named routerc( name, value, overwrite=true )
- Add anRC
value if the route matchedrcAppend map, overwrite=true )
- Add multiple values to theRC
collection if the route matchedprc( name, value, overwrite=true )
- Add anPRC
value if the route matchedprcAppend map, overwrite=true )
- Add multiple values to thePRC
collection if the route matchedwithHandler( handler )
- Map the route to execute a handlerwithAction( action )
- Map the route to execute a single action or a struct that represents verbs and actionswithModule( module )
- Map the route to a modulewithNamespace( namespace )
- Map the route to a namespacewithSSL()
- Force SSLwithCondition( condition )
- Apply a runtime closure/lambda enclosurewithDomain( domain )
- Map the route to a domain or subdomainwithVerbs( verbs )
- Restrict the route to listen to only these HTTP VerbspackageResolver( toggle )
- Turn on/off convention for packagesvaluePairTranslator( toggle )
- Turn on/off automatic name value pair translations
Terminators
Terminators finalize the routing process by registering the route in the Router.
end()
- Register the route as it existstoView( view, layout, noLayout=false, viewModule, layoutModule )
- Send the route to a view/layouttoRedirect( target, statusCode=301 )
- Relocate the route to another eventto( event )
- Execute the event if the route matchestoHandler( handler )
- Execute the handler if the route matchestoResponse( body, statusCode=200, statusText="ok" )
- Inline response actiontoModuleRouting( module )
- Send to the module router for evaluationtoNamespaceRouting( namespace )
- Send to the namespace router for evaluation
Last updated