Default URL mapping
By default, Woof! will use the following algorithm to map a URL to a controller and action.
- Remove the URL root prefix (corresponding to the value of
url_rootin the configuration file) from the presented URL. - Remove the query and fragment components if any from the URL.
- If the remaining fragment is empty, set it to the value of
the configuration variable
app_default_uri_path(which may also be empty). - Split the string on the
/character to get a list of tokens. - If the list has two or more tokens, the last token is the name of the action, and the penultimate token is the name of the controller. Any preceding tokens specify the module.
- If the list has exactly one token, it is the name of the controller.
The action is the value of the configuration variable
app_default_actionif defined, orindexotherwise. The module list is empty. - If the list is empty, the controller is the value of the
configuration variable
app_default_controllerif defined or the configuration variableapp_nameif it is not. The action is the value of the configuration variableapp_default_actionif defined, orindexif not. The module list is empty.
For example, if the application is rooted at
/myapp, the URL
/myapp/alpha/beta/gamma/delta, will
be mapped to the action delta in the controller
gamma in the module {alpha beta}. The
controller class will be GammaController and be loaded
from the file
app/controllers/alpha/beta/gamma_controller.tcl
in the Woof! directory.
Note this default URL mapping is used only if no custom route matches the URL as described in the next section.