Java Reference
In-Depth Information
get("/person/:personid") {
"This is the page for person ${urlparams.personid}"
}
post("/submit") {
// handle form submission here
}
put("/some-resource") {
// create the resource
}
delete("/some-resource") {
// delete the resource
}
The project shows a lot of promise, and Sinatra is very popular in the Ruby world, so it's
probably worth a look. The project has recently come under the control of Luke Daley, who
is a major player in the Groovy world, so I expect significant improvements soon.
9.6.3. Grails and REST
Finally, Grails has REST capabilities as well. For example, in a Grails application you can
edit the URLMappings.groovy file as follows:
static mappings = {
"/product/$id?"(resource:"product")
}
The result is that GET, POST, PUT, and DELETE requests for products will be directed to
the show , save , update , and delete actions in the ProductController , respect-
ively. Grails also automatically parses and generates XML and/or JSON, as desired.
There's also a JAX-RS plugin available for Grails. At the moment it's based on JAX-RS
version 1, but the implementation can use either the Jersey reference implementation or
Restlets. Of course, once again, nothing is said about hypermedia in either case, though
anything you can do in Groovy you can, of course, do in Grails as well.
REST capabilities are a major design goal of Grails 3.0, so by then the situation will no
doubt change.
Search WWH ::




Custom Search