public abstract class GroovyChainAction extends Object implements GroovyChain, Action<Chain>
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"
}
| Constructor and Description |
|---|
GroovyChainAction() |
| Modifier and Type | Method and Description |
|---|---|
GroovyChain |
all(Handler handler)
Adds the given handler to this.
|
abstract void |
execute()
Defines the handler chain.
|
void |
execute(Chain chain)
Invokes
execute() while setting the given chain as the implicit receiver. |
Registry |
getRegistry()
The registry that backs this chain.
|
ServerConfig |
getServerConfig()
The server config of the application that this chain is being created for.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitall, all, chain, delete, delete, delete, delete, delete, delete, files, files, files, fileSystem, fileSystem, fileSystem, from, get, get, get, get, get, get, host, host, host, insert, insert, insert, notFound, onlyIf, onlyIf, onlyIf, onlyIf, onlyIf, onlyIf, options, options, options, options, options, options, patch, patch, patch, patch, patch, patch, path, path, path, path, path, path, post, post, post, post, post, post, prefix, prefix, prefix, put, put, put, put, put, put, redirect, register, register, register, register, register, register, register, register, register, when, when, when, when, when, when, when, when, whenappend, curry, from, ignoreArg, join, noop, noopIfNull, prepend, throwException, throwException, toConsumer, uncheckedWith, uncheckedWith, with, withpublic abstract void execute()
throws Exception
Exception - anypublic final void execute(Chain chain) throws Exception
execute() while setting the given chain as the implicit receiver.public GroovyChain all(Handler handler)
all in interface GroovyChainall in interface Chainhandler - the handler to addpublic ServerConfig getServerConfig()
getServerConfig in interface Chainpublic Registry getRegistry() throws IllegalStateException
What the registry is depends on how the chain was created.
The Handlers.chain(ServerConfig, Registry, Action) allows the registry to be specified.
For a Guice based application, the registry is backed by Guice.
getRegistry in interface ChainIllegalStateException - if there is no backing registry for this chainHandlers.chain(ServerConfig, Registry, Action)