Class HttpPredicateRouterBuilder

java.lang.Object
io.servicetalk.http.router.predicate.HttpPredicateRouterBuilder
All Implemented Interfaces:
RouteStarter

public final class HttpPredicateRouterBuilder extends Object implements RouteStarter
Builds a 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.