Creating Routes

The Config Folder

In the root of the site is the CONFIG folder which holds several files which can be used to configure nearly everything about how ColdBox behaves. One of those is Router.cfc which can be used to explicitly define routes.

Out of the box, there are several routes already established including a healthcheck and a few examples.

  1. Open config/Router.cfc

  2. In the companion app go to COLDBOX --> Getting Started. Plug some of the sample routes into the text box and send them. See the response in the XHR Details panel.

Creating A Route

  1. Find an open space in the config/Router.cfc and add the line\

    route("/users").withAction({GET:"index"}).toHandler("Users");

This break down into 3 parts - The URI pattern - The method called based on what verb is in the request - The handler which contains that method.

Last updated