6.10 Routing reference
6.10.1 Basic syntax rules
As mentioned elsewhere, the routing configuration syntax is essentially a program written in the Groovy language.
However, don't let that scare you away with the thought of having to learn yet another language, since you get can a long way without knowing Groovy.
You can pick up the syntax by looking at some examples, such as this:
builder.router {
restlet(uri: "/helloworld1", ofClass: "org.mycomp.HelloWorld1")
restlet(uri: "/hello/world2", ofClass: org.mycomp.HelloWorld2")
router(uri: "/hello") {
restlet(uri: "/world3", ofClass: org.mycomp.HelloWorld3")
}
}
In case you're wondering, this example will react on URIs starting with:
/helloworld1 /hello/world2 /hello/world3
From this example you can see the basic rules:
- components names are optionally followed by a set of parameters between brackets
- the parameters are a comma-separated list of name value-pairs, the name and value separated by a colon
- components nested inside another component are listed within curly brackets following the component
- the top-level component (usually a 'router') is prefixed with 'builder.'
Previous