Class HttpPredicateRouterBuilder

  • All Implemented Interfaces:
    RouteStarter

    public final class HttpPredicateRouterBuilder
    extends java.lang.Object
    implements RouteStarter
    Builds an StreamingHttpService which routes requests to a number of other StreamingHttpServices based on user specified criteria.

    eg.

    
     final StreamingHttpService<HttpChunk, HttpChunk> router = new HttpPredicateRouterBuilder<HttpChunk, HttpChunk>()
         .whenMethod(GET).andPathStartsWith("/a/").thenRouteTo(serviceA)
         .whenMethod(GET).andPathStartsWith("/b/").thenRouteTo(serviceB)
         .whenMethod(POST).thenRouteTo(serviceC)
         .buildStreaming();
     

    If no routes match, a default service is used, which returns a 404 response.