public interface GroovyChain extends Chain
The methods specific to this subclass create Handler
instances from closures and
add them to the underlying chain.
These methods are generally shortcuts for handler(ratpack.handling.Handler)
on this underlying chain.
Modifier and Type | Method and Description |
---|---|
GroovyChain |
assets(String path,
String... indexFiles)
Adds a
Handler to this GroovyChain that serves static assets at the given file system path,
relative to the contextual file system binding. |
GroovyChain |
delete(Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler
if the request HTTPMethod is DELETE and the path is at the current root. |
GroovyChain |
delete(Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given Handler if
the request HTTPMethod is DELETE and the path is at the current root. |
GroovyChain |
delete(String path,
Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler if the
relative path matches the given path and the request HTTPMethod is DELETE . |
GroovyChain |
delete(String path,
Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given Handler if
the relative path matches the given path and the request HTTPMethod
is DELETE . |
GroovyChain |
fileSystem(String path,
Action<? super Chain> action) |
GroovyChain |
fileSystem(String path,
Closure<?> handlers)
Creates a
List of Handler from the given Closure and adds a Handler to this GroovyChain that
changes the FileSystemBinding for the Handler list. |
GroovyChain |
fileSystem(String path,
Handler handler)
|
GroovyChain |
get(Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler
if the request HTTPMethod is GET and the path is at the current root. |
GroovyChain |
get(Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given Handler
if the request HTTPMethod is GET and the path is at the
current root. |
GroovyChain |
get(String path,
Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler if the
relative path matches the given path and the request HTTPMethod is GET . |
GroovyChain |
get(String path,
Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given Handler
if the relative path matches the given path and the request
HTTPMethod is GET . |
GroovyChain |
handler(Closure<?> handler)
Adds the given
Closure as a Handler to this GroovyChain . |
GroovyChain |
handler(Handler handler)
Adds the given
Handler to this GroovyChain . |
GroovyChain |
handler(String path,
Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler if the
relative path matches the given path exactly. |
GroovyChain |
handler(String path,
Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given Handler if the relative path
matches the given path exactly. |
GroovyChain |
header(String headerName,
String headerValue,
Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler if the request
has a HTTPHeader with the given name and a it's value matches the given value exactly. |
GroovyChain |
header(String headerName,
String headerValue,
Handler handler)
Adds a
Handler to the chain that delegates to the given handler if the request has a header with the given name and a its value matches the given value exactly. |
GroovyChain |
patch(Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler
if the request HTTPMethod is PATCH and the path is at the current root. |
GroovyChain |
patch(Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given Handler if
the request HTTPMethod is PATCH and the path is at the current root. |
GroovyChain |
patch(String path,
Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler if the
relative path matches the given path and the request HTTPMethod is PATCH . |
GroovyChain |
patch(String path,
Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given Handler if
the relative path matches the given path and the request HTTPMethod
is PATCH . |
GroovyChain |
post(Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler
if the request HTTPMethod is POST and the path is at the current root. |
GroovyChain |
post(Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given Handler if
the request HTTPMethod is POST and the path is at the current root. |
GroovyChain |
post(String path,
Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler if the
relative path matches the given path and the request HTTPMethod is POST . |
GroovyChain |
post(String path,
Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given Handler if
the relative path matches the given path and the request HTTPMethod
is POST . |
GroovyChain |
prefix(String prefix,
Action<? super Chain> action) |
GroovyChain |
prefix(String prefix,
Closure<?> chain)
Creates a
List of Handler from the given Closure and adds a Handler to
this GroovyChain that delegates to the Handler list if the relative path starts with the given
prefix . |
GroovyChain |
prefix(String prefix,
Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given handlers if the
relative path starts with the given prefix . |
GroovyChain |
put(Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler
if the request HTTPMethod is PUT and the path is at the current root. |
GroovyChain |
put(Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given Handler if
the request HTTPMethod is PUT and the path is at the current root. |
GroovyChain |
put(String path,
Closure<?> handler)
Adds a
Handler to this GroovyChain that delegates to the given Closure as a Handler if the
relative path matches the given path and the request HTTPMethod is PUT . |
GroovyChain |
put(String path,
Handler handler)
Adds a
Handler to this GroovyChain that delegates to the given Handler if
the relative path matches the given path and the request HTTPMethod
is PUT . |
<T> GroovyChain |
register(Class<? super T> type,
T service,
Action<? super Chain> action) |
<T> GroovyChain |
register(Class<? super T> type,
T service,
Closure<?> handlers)
Creates a
List of Handler from the given Closure and adds a Handler to this GroovyChain that
inserts the the Handler list with the given service addition. |
<T> GroovyChain |
register(Class<? super T> type,
T object,
Handler handler)
Adds a
Handler to this GroovyChain that inserts the given handlers with the given service addition. |
GroovyChain |
register(Object service,
Action<? super Chain> action) |
GroovyChain |
register(Object service,
Closure<?> handlers)
Creates a
List of Handler from the given Closure and adds a Handler to this GroovyChain
that inserts the Handler list with the given service addition. |
GroovyChain |
register(Object object,
Handler handler)
Adds a
Handler to this GroovyChain that inserts the given handler with the given service addition. |
chain, getLaunchConfig, getRegistry
GroovyChain handler(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Closure
as a Handler
to this GroovyChain
.handler
- the Closure
to addGroovyChain
GroovyChain handler(String path, @DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the
relative path
matches the given path
exactly.
See handler(String, ratpack.handling.Handler)
for more details.
path
- the relative path to match exactly onhandler
- the handler to delegate toGroovyChain
GroovyChain handler(Handler handler)
Handler
to this GroovyChain
.GroovyChain prefix(String prefix, Handler handler)
Handler
to this GroovyChain
that delegates to the given handlers if the
relative path starts with the given prefix
.
All path based handlers become relative to the given prefix
.
chain .prefix("person/:id", chain.chain(new Action<Chain>() { public void execute(Chain personChain) { personChain .get("info", new Handler() { public void handle(Context context) { // e.g. /person/2/info } }) .post("save", new Handler() { public void handle(Context context) { // e.g. /person/2/save } }) .prefix("child/:childId", chain.chain(new Action<Chain>() { public void execute(Chain childChain) { childChain .get("info", new Handler() { public void handle(Context context) { // e.g. /person/2/child/1/info } }); } })); } }));
See Handlers.prefix(String, Handler)
for format details on the prefix
string.
GroovyChain prefix(String prefix, Action<? super Chain> action) throws Exception
GroovyChain prefix(String prefix, @DelegatesTo(value=GroovyChain.class,strategy=1) Closure<?> chain) throws Exception
List
of Handler
from the given Closure
and adds a Handler
to
this GroovyChain
that delegates to the Handler
list if the relative path starts with the given
prefix
.
See Chain.prefix(String, ratpack.handling.Handler)
for more details.
prefix
- the relative path to match onchain
- the definition of the chain to delegate toGroovyChain
Exception
GroovyChain handler(String path, Handler handler)
Handler
to this GroovyChain
that delegates to the given Handler
if the relative path
matches the given path
exactly.
Nesting path
handlers will not work due to the exact matching, use a combination of path
and prefix
instead. See Chain.prefix(String, Handler)
for details.
// this will not work path("person/:id") { path("child/:childId") { // a request of /person/2/child/1 will not get passed the first handler as it will try // to match "person/2/child/1" with "person/2" which does not match } // this will work prefix("person/:id") { path("child/:childId") { // a request of /person/2/child/1 will work this time } }
See Handlers.path(String, Handler)
for the details on how path
is interpreted.
handler
in interface Chain
path
- the relative path to match exactly onhandler
- the handler to delegate toGroovyChain
Chain.post(String, Handler)
,
Chain.get(String, Handler)
,
Chain.put(String, Handler)
,
Chain.patch(String, Handler)
,
Chain.delete(String, Handler)
GroovyChain get(Handler handler)
Handler
to this GroovyChain
that delegates to the given Handler
if the request
HTTPMethod
is GET
and the path
is at the
current root.get
in interface Chain
handler
- the handler to delegate toGroovyChain
Chain.post(Handler)
,
Chain.put(Handler)
,
Chain.patch(Handler)
,
Chain.delete(Handler)
GroovyChain get(String path, Handler handler)
Handler
to this GroovyChain
that delegates to the given Handler
if the relative path
matches the given path
and the request
HTTPMethod
is GET
.
get
in interface Chain
path
- the relative path to match onhandler
- the handler to delegate toGroovyChain
Chain.post(String, Handler)
,
Chain.put(String, Handler)
,
Chain.patch(String, Handler)
,
Chain.delete(String, Handler)
,
Chain.handler(String, Handler)
GroovyChain get(String path, @DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the
relative path
matches the given path
and the request
HTTPMethod
is GET
.
See get(String, ratpack.handling.Handler)
for more details.
path
- the relative path to match onhandler
- the handler to delegate toGroovyChain
GroovyChain get(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the request
HTTPMethod
is GET
and the path
is at the current root.
See get(ratpack.handling.Handler)
for more details.
handler
- the handler to delegate toGroovyChain
GroovyChain post(String path, Handler handler)
Handler
to this GroovyChain
that delegates to the given Handler
if
the relative path
matches the given path
and the request
HTTPMethod
is POST
.
post
in interface Chain
path
- the relative path to match onhandler
- the handler to delegate toGroovyChain
Chain.get(String, Handler)
,
Chain.put(String, Handler)
,
Chain.patch(String, Handler)
,
Chain.delete(String, Handler)
,
Chain.handler(String, Handler)
GroovyChain post(String path, @DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the
relative path
matches the given path
and the request
HTTPMethod
is POST
.
See post(String, ratpack.handling.Handler)
for more details.
path
- the relative path to match onhandler
- the handler to delegate toGroovyChain
GroovyChain post(Handler handler)
Handler
to this GroovyChain
that delegates to the given Handler
if
the request
HTTPMethod
is POST
and the path
is at the current root.
post
in interface Chain
handler
- the handler to delegate toGroovyChain
Chain.get(Handler)
,
Chain.put(Handler)
,
Chain.patch(Handler)
,
Chain.delete(Handler)
GroovyChain post(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the request
HTTPMethod
is POST
and the path
is at the current root.
See post(ratpack.handling.Handler)
for more details.
handler
- the handler to delegate toGroovyChain
GroovyChain put(Handler handler)
Handler
to this GroovyChain
that delegates to the given Handler
if
the request
HTTPMethod
is PUT
and the path
is at the current root.put
in interface Chain
handler
- the handler to delegate toGroovyChain
Chain.get(Handler)
,
Chain.post(Handler)
,
Chain.patch(Handler)
,
Chain.delete(Handler)
GroovyChain put(String path, Handler handler)
Handler
to this GroovyChain
that delegates to the given Handler
if
the relative path
matches the given path
and the request
HTTPMethod
is PUT
.put
in interface Chain
path
- the relative path to match onhandler
- the handler to delegate toGroovyChain
Chain.get(String, Handler)
,
Chain.post(String, Handler)
,
Chain.patch(String, Handler)
,
Chain.delete(String, Handler)
,
Chain.handler(String, Handler)
GroovyChain put(String path, @DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the
relative path
matches the given path
and the request
HTTPMethod
is PUT
.
See put(String, ratpack.handling.Handler)
for more details.
path
- the relative path to match onhandler
- the handler to delegate toGroovyChain
GroovyChain put(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the request
HTTPMethod
is PUT
and the path
is at the current root.
See put(ratpack.handling.Handler)
for more details.
handler
- the handler to delegate toGroovyChain
GroovyChain patch(Handler handler)
Handler
to this GroovyChain
that delegates to the given Handler
if
the request
HTTPMethod
is PATCH
and the path
is at the current root.patch
in interface Chain
handler
- the handler to delegate toGroovyChain
Chain.get(Handler)
,
Chain.post(Handler)
,
Chain.put(Handler)
,
Chain.delete(Handler)
GroovyChain patch(String path, Handler handler)
Handler
to this GroovyChain
that delegates to the given Handler
if
the relative path
matches the given path
and the request
HTTPMethod
is PATCH
.patch
in interface Chain
path
- the relative path to match onhandler
- the handler to delegate toGroovyChain
Chain.get(String, Handler)
,
Chain.post(String, Handler)
,
Chain.put(String, Handler)
,
Chain.delete(String, Handler)
,
Chain.handler(String, Handler)
GroovyChain patch(String path, @DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the
relative path
matches the given path
and the request
HTTPMethod
is PATCH
.
See put(String, ratpack.handling.Handler)
for more details.
path
- the relative path to match onhandler
- the handler to delegate toGroovyChain
GroovyChain patch(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the request
HTTPMethod
is PATCH
and the path
is at the current root.
See put(ratpack.handling.Handler)
for more details.
handler
- the handler to delegate toGroovyChain
GroovyChain delete(Handler handler)
Handler
to this GroovyChain
that delegates to the given Handler
if
the request
HTTPMethod
is DELETE
and the path
is at the current root.delete
in interface Chain
handler
- the handler to delegate toGroovyChain
Chain.get(Handler)
,
Chain.post(Handler)
,
Chain.put(Handler)
,
Chain.patch(Handler)
GroovyChain delete(String path, Handler handler)
Handler
to this GroovyChain
that delegates to the given Handler
if
the relative path
matches the given path
and the request
HTTPMethod
is DELETE
.delete
in interface Chain
path
- the relative path to match onhandler
- the handler to delegate toGroovyChain
Chain.get(String, Handler)
,
Chain.post(String, Handler)
,
Chain.put(String, Handler)
,
Chain.patch(String, Handler)
,
Chain.handler(String, Handler)
GroovyChain delete(String path, @DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the
relative path
matches the given path
and the request
HTTPMethod
is DELETE
.
See delete(String, ratpack.handling.Handler)
for more details.
path
- the relative path to match onhandler
- the handler to delegate toGroovyChain
GroovyChain delete(@DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the request
HTTPMethod
is DELETE
and the path
is at the current root.
See delete(ratpack.handling.Handler)
for more details.
handler
- the handler to delegate toGroovyChain
GroovyChain register(Object object, Handler handler)
Handler
to this GroovyChain
that inserts the given handler with the given service
addition.
The service
object will be available by its concrete type.
See Handlers.register(Object, Handler)
for more details on the Handler
created
register
in interface Chain
object
- the object to add to the service for the handlershandler
- the handlers to register the service withGroovyChain
Chain.register(Class, Object, Handler)
GroovyChain register(Object service, Action<? super Chain> action) throws Exception
GroovyChain register(Object service, @DelegatesTo(value=GroovyChain.class,strategy=1) Closure<?> handlers) throws Exception
List
of Handler
from the given Closure
and adds a Handler
to this GroovyChain
that inserts the Handler
list with the given service
addition.
See register(Object, Handler)
for more details.
service
- the object to add to the service for the handlershandlers
- the handlers to register the service withGroovyChain
Exception
<T> GroovyChain register(Class<? super T> type, T object, Handler handler)
Handler
to this GroovyChain
that inserts the given handlers with the given service
addition.
The service
object will be available by the given type.
See Handlers.register(Class, Object, Handler)
for more details on the Handler
created
register
in interface Chain
T
- the concrete type of the service additiontype
- the Type
by which to make the service object availableobject
- the object to add to the service for the handlershandler
- the handlers to register the service withGroovyChain
Chain.register(Object, Handler)
<T> GroovyChain register(Class<? super T> type, T service, Action<? super Chain> action) throws Exception
<T> GroovyChain register(Class<? super T> type, T service, @DelegatesTo(value=GroovyChain.class,strategy=1) Closure<?> handlers) throws Exception
List
of Handler
from the given Closure
and adds a Handler
to this GroovyChain
that
inserts the the Handler
list with the given service
addition.
See register(Class, Object, Handler)
for more details.
T
- the concrete type of the service additiontype
- the Type
by which to make the service object availableservice
- the object to add to the service for the handlershandlers
- the handlers to register the service withGroovyChain
Exception
GroovyChain assets(String path, String... indexFiles)
Handler
to this GroovyChain
that serves static assets at the given file system path,
relative to the contextual file system binding.
See Handlers.assets(String, java.util.List)
for more details on the Handler
created
prefix("foo") { assets("d1", "index.html", "index.xhtml") }In the above configuration a request like "/foo/app.js" will return the static file "app.js" that is located in the directory "d1".
If the request matches a directory e.g. "/foo", an index file may be served. The indexFiles
array specifies the names of files to look for in order to serve.
GroovyChain fileSystem(String path, Handler handler)
fileSystem
in interface Chain
path
- the relative path
to the new file system binding pointhandler
- the definition of the handler chainGroovyChain
GroovyChain fileSystem(String path, Action<? super Chain> action) throws Exception
fileSystem
in interface Chain
Exception
GroovyChain fileSystem(String path, @DelegatesTo(value=GroovyChain.class,strategy=1) Closure<?> handlers) throws Exception
List
of Handler
from the given Closure
and adds a Handler
to this GroovyChain
that
changes the FileSystemBinding
for the Handler
list.
See fileSystem(String, Handler)
for more details.
path
- the relative path
to the new file system binding pointhandlers
- the definition of the handler chainGroovyChain
Exception
GroovyChain header(String headerName, String headerValue, Handler handler)
Handler
to the chain that delegates to the given handler if the request has a header with the given name and a its value matches the given value exactly.
GroovyChain header(String headerName, String headerValue, @DelegatesTo(value=GroovyContext.class,strategy=1) Closure<?> handler)
Handler
to this GroovyChain
that delegates to the given Closure
as a Handler
if the request
has a HTTPHeader
with the given name and a it's value matches the given value exactly.
See header(String, String, ratpack.handling.Handler)
for more details.
headerName
- the name of the HTTP Header to match onheaderValue
- the value of the HTTP Header to match onhandler
- the handler to delegate toGroovyChain