@Test public void testMerge() { HttpRequest request1 = HttpRequest.get(TEMPLATE + "/"); HttpRequest request2 = HttpRequest.get(TEMPLATE + "/a"); HttpRequest request3 = HttpRequest.get(TEMPLATE + "/b"); HttpRequest request4 = HttpRequest.get(TEMPLATE + "/a/c"); HttpRequest request5 = HttpRequest.get(TEMPLATE + "/a/d"); HttpRequest request6 = HttpRequest.get(TEMPLATE + "/a/e"); HttpRequest request7 = HttpRequest.get(TEMPLATE + "/a/c/f"); AsyncServlet action = request -> { ByteBuf msg = wrapUtf8("Executed: " + request.getPath()); return HttpResponse.ofCode(200).withBody(msg); }; RoutingServlet main = RoutingServlet.create() .map(GET, "/a", action) .map(GET, "/a/c", action) .map(GET, "/a/d", action) .map(GET, "/b", action) .merge(RoutingServlet.create() .map(GET, "/", action) .map(GET, "/a/e", action) .map(GET, "/a/c/f", action)); System.out.println("Merge " + DELIM); check(main.serve(request1), "Executed: /", 200); check(main.serve(request2), "Executed: /a", 200); check(main.serve(request3), "Executed: /b", 200); check(main.serve(request4), "Executed: /a/c", 200); check(main.serve(request5), "Executed: /a/d", 200); check(main.serve(request6), "Executed: /a/e", 200); check(main.serve(request7), "Executed: /a/c/f", 200); System.out.println(); }
@Contract("_ -> new") public RoutingServlet merge(RoutingServlet servlet) { return merge(ROOT, servlet); }
RoutingServlet implements AsyncServlet, Initializable<RoutingServlet> { @Contract("_ -> new") public RoutingServlet merge(RoutingServlet servlet) { return merge(ROOT, servlet); } }
RoutingServlet implements AsyncServlet, Initializable<RoutingServlet> { @Contract("_ -> new") public RoutingServlet merge(RoutingServlet servlet) { return merge(ROOT, servlet); } private  RoutingServlet(); }
RoutingServlet implements AsyncServlet, Initializable<RoutingServlet> { @Contract("_ -> new") public RoutingServlet merge(RoutingServlet servlet) { return merge(ROOT, servlet); } private  RoutingServlet(); static RoutingServlet create(); static RoutingServlet wrap(AsyncServlet servlet); RoutingServlet map(@NotNull String path, @NotNull AsyncServlet servlet); RoutingServlet map(@NotNull String path, @NotNull AsyncServlet servlet, @NotNull BinaryOperator<AsyncServlet> merger); @Contract("_, _, _ -> this") RoutingServlet map(@Nullable HttpMethod method, @NotNull String path, @NotNull AsyncServlet servlet); @Contract("_, _, _, _ -> this") RoutingServlet map(@Nullable HttpMethod method, @NotNull String path, @NotNull AsyncServlet servlet, @NotNull BinaryOperator<AsyncServlet> merger); void visit(Visitor visitor); @Nullable RoutingServlet getSubtree(String path); @Contract("_ -> new") RoutingServlet merge(RoutingServlet servlet); @Contract("_, _ -> new") RoutingServlet merge(String path, RoutingServlet servlet); @Contract("_, _, _ -> new") RoutingServlet merge(String path, RoutingServlet servlet, BinaryOperator<AsyncServlet> merger); @NotNull @Override Promise<HttpResponse> serve(@NotNull HttpRequest request); static RoutingServlet merge(RoutingServlet first, RoutingServlet second); static RoutingServlet merge(RoutingServlet... servlets); static RoutingServlet merge(RoutingServlet first, RoutingServlet second, BinaryOperator<AsyncServlet> merger); static RoutingServlet merge(BinaryOperator<AsyncServlet> merger, RoutingServlet... servlets); }
RoutingServlet implements AsyncServlet, Initializable<RoutingServlet> { @Contract("_ -> new") public RoutingServlet merge(RoutingServlet servlet) { return merge(ROOT, servlet); } private  RoutingServlet(); static RoutingServlet create(); static RoutingServlet wrap(AsyncServlet servlet); RoutingServlet map(@NotNull String path, @NotNull AsyncServlet servlet); RoutingServlet map(@NotNull String path, @NotNull AsyncServlet servlet, @NotNull BinaryOperator<AsyncServlet> merger); @Contract("_, _, _ -> this") RoutingServlet map(@Nullable HttpMethod method, @NotNull String path, @NotNull AsyncServlet servlet); @Contract("_, _, _, _ -> this") RoutingServlet map(@Nullable HttpMethod method, @NotNull String path, @NotNull AsyncServlet servlet, @NotNull BinaryOperator<AsyncServlet> merger); void visit(Visitor visitor); @Nullable RoutingServlet getSubtree(String path); @Contract("_ -> new") RoutingServlet merge(RoutingServlet servlet); @Contract("_, _ -> new") RoutingServlet merge(String path, RoutingServlet servlet); @Contract("_, _, _ -> new") RoutingServlet merge(String path, RoutingServlet servlet, BinaryOperator<AsyncServlet> merger); @NotNull @Override Promise<HttpResponse> serve(@NotNull HttpRequest request); static RoutingServlet merge(RoutingServlet first, RoutingServlet second); static RoutingServlet merge(RoutingServlet... servlets); static RoutingServlet merge(RoutingServlet first, RoutingServlet second, BinaryOperator<AsyncServlet> merger); static RoutingServlet merge(BinaryOperator<AsyncServlet> merger, RoutingServlet... servlets);  }