public final class TsFork extends Object implements Takes
This is the implementation of Takes
that
routes the requests to another takes, using a collection of forks
to pick the right one. The best example is a routing by regular
expression, for example:
Takes takes = new TsFork( new FkRegex("/home", new TsHome()), new FkRegex("/account", new TsAccount()) );
Here, TsFork
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.AtTake
.
The class is immutable and thread-safe.
FkMethods
,
FkRegex
,
FkParams
Constructor and Description |
---|
TsFork()
Ctor.
|
TsFork(Collection<Fork.AtTake> frks)
Ctor.
|
TsFork(Fork.AtTake... frks)
Ctor.
|
public TsFork()
public TsFork(Fork.AtTake... frks)
frks
- Forkspublic TsFork(Collection<Fork.AtTake> frks)
frks
- Forkspublic Take route(Request request) throws IOException
Takes
route
in interface Takes
request
- The request to dispatchIOException
- If failsCopyright © 2015 Takes. All rights reserved.