Class VirtualHostServiceBindingBuilder

java.lang.Object
com.linecorp.armeria.server.VirtualHostServiceBindingBuilder

public final class VirtualHostServiceBindingBuilder extends Object
A builder class for binding an HttpService fluently. This class can be instantiated through VirtualHostBuilder.route(). You can also configure an HttpService using VirtualHostBuilder.withRoute(Consumer).

Call build(HttpService) to build the HttpService and return to the VirtualHostBuilder.


 ServerBuilder sb = Server.builder();
 sb.virtualHost("example.com")
   .route()                                      // Configure the first service in "example.com".
   .post("/foo/bar")
   .consumes(JSON, PLAIN_TEXT_UTF_8)
   .produces(JSON_UTF_8)
   .requestTimeoutMillis(5000)
   .maxRequestLength(8192)
   .verboseResponses(true)
   .build((ctx, req) -> HttpResponse.of(OK));    // Return to the VirtualHostBuilder.

 sb.virtualHost("example2.com")                  // Configure the second service "example2.com".
   .withRoute(builder -> builder.path("/baz")
                                .methods(HttpMethod.GET, HttpMethod.POST)
                                .build((ctx, req) -> HttpResponse.of(OK)));
 
See Also:
ServiceBindingBuilder