Class ServiceBindingBuilder

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

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

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


 ServerBuilder sb = Server.builder();

 sb.route()                                      // Configure the first service.
   .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 ServerBuilder.

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