Skip to end of metadata
Go to start of metadata

Examples of how to construct Restlet applications mentioned in Restlet Tutorials
For example groovy scripts, see http://svn.codehaus.org/groovy-contrib/groovyrestlet/trunk/src/test/groovy/org/lpny/groovyrestlet/examples/tutorials/

Example of Part02

Example about creating a Restlet Client instance.

You can use shortcut client constructor as shown in `#1`; also you can use the generic restlet constructor to create client instance.

Icon

you can use `restlet(ofClass:class name)` to create any instance of derived type of Restlet. In this case, you need to specify attribute `consArgs` which are an array of constructing parameters.

Create client
Example of Part03

At current moment, server construction does not support `restlet` way

Nesting here indicates a parent-child relationship.

Icon

The child of a server component becoming the target property of the Server.

Create a server
Example of Part05
Restlet example
Example of Part06
Serving static files
Example of Part09
Icon

Using current to reference to the current instance.

By default any nested component will be automatically attached to its parent component according to their parent-child relationship. Here Guard is automatically attached to its parent (Application here) as its root. Adding attribute autoAttach:false can disable this feature.

Guard
Example of Part10

In Restlet, an attaching operation (on Router.attach) returns an instance of Route. It might be needed to do some post processing on a route. Attribute postAttach which refers a closure is used to support this.

Redirector example
Example of Part11
Icon

You can implement the handle method of a Restlet using a groovy closure.

Router
Example of Part12

Same as handle closure of a Restlet, you can implement a simple Restlet Resource using groovy closures. Following attributes are supported:

  • init: init method
  • represent: for represent() and represent(Variant) methods HTTP GET
  • store: for storeRepresentation() method HTTP PUT
  • remove: for remoteRepresentation() method HTTP DELETE
  • accept: for acceptRepresentation() method HTTP POST
  • head: for handleHead() method
  • options: for handleOptions method
    Icon

    Specify `self` parameter in the last of parameter list. This special `self` instance indicates the resource instance.

    Resources
  • No labels