Return to v2.5.0 docs

wildcard()


Configuration Routing struct mapper


Special wildcard matching generates routes with `

Name Type Required Default Description
method string No get List of HTTP methods (verbs) to generate the wildcard routes for. We strongly recommend leaving the default value of get and using other routing mappers if you need to POST to a URL endpoint. For better readability, you can also pass this argument as methods if you're listing multiple methods.
action string No index Default action to specify if the value for the [action] placeholder is not provided.
mapKey boolean No false Whether or not to enable a [key] matcher, enabling a [controller]/[action]/[key] pattern.
mapFormat boolean No false Whether or not to add an optional .[format] pattern to the end of the generated routes. This is useful for providing formats via URL like json, xml, pdf, etc.
<cfscript>

mapper()
    // Enables `[controller]` and `[controller]/[action]`, only via `GET` requests.
    .wildcard()

    // Enables `[controller]/[action]/[key]` as well.
    .wildcard(mapKey=true)

    // Also enables patterns like `[controller].[format]` and
    // `[controller]/[action].[format]`
    .wildcard(mapFormat=true)

    // Allow additional methods beyond just `GET`
    //
    // Note that this can open some serious security holes unless you use `verifies`
    // in the controller to make sure that requests changing data can only occur
    // with a `POST` method.
    .wildcard(methods="get,post")
.end();

</cfscript>

Related Functions

Routing