Java Reference
In-Depth Information
The groovlet uses
request.method
in a
switch
statement to determine the correct
implementation. Then it uses a built-in
MarkupBuilder
called
html
to produce XML,
and an
XmlSlurper
to convert XML to song instances. Now that groovlets have a builtin
22
That's my great contribution to Groovy—the implicit
json
object in groovlets, which I not only added, but with
which I managed to break the build in the process. Sigh. If you're interested, details can be found at
http://mng.bz/
This approach is pretty low-level, but it may be useful for quick-and-dirty implementations
or if you need such detailed control.
9.6.2. Ratpack
The second alternative is to look at the Ratpack project (
https://github.com/ratpack/rat-
the Ruby world. Ratpack is called a “micro” framework, in that you write simple Groovy
scripts that govern how to handle individual requests.
23
Sinatra, Ratpack, get it? If nothing else, it's a great name.
For example, a simple Ratpack script looks like this: