Class GroovyChainAction

  • All Implemented Interfaces:
    Chain, Action<Chain>, GroovyChain

    public abstract class GroovyChainAction
    extends Object
    implements GroovyChain, Action<Chain>
    A convenience super class for a standalone implementation of a Action<GroovyChain>.

    Subclasses implement the execute() method, and implicitly program against the GroovyChain DSL.

    
     import ratpack.groovy.handling.GroovyChainAction
     import ratpack.groovy.test.embed.GroovyEmbeddedApp
    
     class Handlers extends GroovyChainAction {
       public void execute() throws Exception {
         path { render "root" }
         prefix("foo") {
           path("bar") { render "foobar" }
         }
       }
     }
    
     GroovyEmbeddedApp.of {
       handlers new Handlers()
     } test {
       assert getText() == "root"
       assert getText("foo/bar") == "foobar"
     }