public final class TkFork extends Object implements Take
This is the implementation of Take
that
routes the requests to another take, using a collection of forks
to pick the right one. The best example is a routing by regular
expression, for example:
Take take = new TkFork( new FkRegex("/home", new TkHome()), new FkRegex("/account", new TkAccount()) );
Here, TkFork
will try to call these
"forks" one by one, asking whether they accept the request. The first
one that reacts will get control. Each "fork" is an implementation
of Fork
.
The class is immutable and thread-safe.
public TkFork()
public TkFork(Fork... frks)
frks
- Forkspublic TkFork(Collection<Fork> frks)
frks
- Forkspublic Response act(Request request) throws IOException
Take
act
in interface Take
request
- Request to processIOException
- If failsCopyright © 2015–2019 Take. All rights reserved.