(Quick Reference)

6.4.1 Mapping to Controllers and Actions - Reference Documentation

Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith

Version: null

6.4.1 Mapping to Controllers and Actions

To create a simple mapping simply use a relative URL as the method name and specify named parameters for the controller and action to map to:

Para crear un mapeo simple, simplemente use una URL relativa como el nombre del metodo y especifique los parametros nombrados para el controlador y la accion a mapear:

"/product"(controller: "product", action: "list")

In this case we've mapped the URL /product to the list action of the ProductController. Omit the action definition to map to the default action of the controller:

En este caso hemos mapeado la URL /product hacia la accion list del ProductController. Omitiendo la definicion de la accion a mapear hacia la accion por defecto del controllador:

"/product"(controller: "product")

An alternative syntax is to assign the controller and action to use within a block passed to the method:

Una sintaxis alternativa es asignar el controlador y la accion a usar dentro del bloque pasado al metodo:

"/product" {
    controller = "product"
    action = "list"
}

Which syntax you use is largely dependent on personal preference. To rewrite one URI onto another explicit URI (rather than a controller/action pair) do something like this:

Cual sintaxis usar es enormemente dependiente en su preferencia personal. Para reescribir una URI en otra URI explicita (en vez del par controlador/accion) haga algo asi:

"/hello"(uri: "/hello.dispatch")

Rewriting specific URIs is often useful when integrating with other frameworks

Reescribir URIs especificas es comunmente util cuando se integran con otros frameworks.