Class TkFork

  • All Implemented Interfaces:
    Take

    public final class TkFork
    extends Object
    implements Take
    Fork 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.

    Since:
    0.4
    See Also:
    FkMethods, FkRegex, FkParams
    • Constructor Detail

      • TkFork

        public TkFork()
        Ctor.
      • TkFork

        public TkFork​(Fork... frks)
        Ctor.
        Parameters:
        frks - Forks
      • TkFork

        public TkFork​(Collection<Fork> frks)
        Ctor.
        Parameters:
        frks - Forks
    • Method Detail

      • act

        public Response act​(Request request)
                     throws Exception
        Description copied from interface: Take
        Convert request to response.
        Specified by:
        act in interface Take
        Parameters:
        request - Request to process
        Returns:
        Response
        Throws:
        Exception - If fails