Configuration
mapper()
Signature
Section titled “Signature”mapper() — returns struct
Available in: controller, model, test, migrator, migration, tabledefinition
Category: Routing
Description
Section titled “Description”Returns the mapper object used to configure your application’s routes. Usually you will use this method in app/config/routes.cfm to start chaining route mapping methods like resources, namespace, etc.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
restful | boolean | no | true | Whether to turn on RESTful routing or not. Not recommended to set. Will probably be removed in a future version of wheels, as RESTful routes are the default. |
methods | boolean | no | [runtime expression] | If not RESTful, then specify allowed routes. Not recommended to set. Will probably be removed in a future version of wheels, as RESTful routes are the default. |
mapFormat | boolean | no | true | This is useful for providing formats via URL like json, xml, pdf, etc. Set to false to disable automatic .[format] generation for resource based routes |
Examples
Section titled “Examples”1. Basic Usage
<cfscript>
mapper()
.resources("posts") // generates standard RESTful routes for posts
.get(name="about", pattern="about-us", to="pages##about") // custom GET route
.namespace("admin") // group routes under admin namespace
.resources("users") // RESTful routes for admin users
.end();
</cfscript>
2. Disable format mapping
mapper(mapFormat=false)
.resources("reports");
// This will prevent automatic generation of .json or .xml endpoints for the resource.