////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////

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:

[source,groovy]
----
"/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:

[source,groovy]
----
"/product"(controller: "product")
----

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

[source,groovy]
----
"/product" {
    controller = "product"
    action = "list"
}
----

Which syntax you use is largely dependent on personal preference. 

If you have mappings that all fall under a particular path you can group mappings with the `group` method:

[source,groovy]
----
group "/product", {
    "/apple"(controller:"product", id:"apple")
    "/htc"(controller:"product", id:"htc")
}
----

You can also create nested `group` url mappings:

[source,groovy]
----
group "/store", {
    group "/product", {
        "/$id"(controller:"product")
    }
}
----


To rewrite one URI onto another explicit URI (rather than a controller/action pair) do something like this:

[source,groovy]
----
"/hello"(uri: "/hello.dispatch")
----

Rewriting specific URIs is often useful when integrating with other frameworks.
