Class VirtualHostDecoratingServiceBindingBuilder

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

public final class VirtualHostDecoratingServiceBindingBuilder
extends Object
A builder class for binding a decorator to a Route fluently. This class can be instantiated through VirtualHostBuilder.routeDecorator().

Call build(Function) or build(DecoratingHttpServiceFunction) to build the decorator and return to the VirtualHostBuilder.


 ServerBuilder sb = Server.builder();

 sb.virtualHost("example.com")
   .routeDecorator()                                // Configure a decorator with route.
   .pathPrefix("/api/users")
   .build((delegate, ctx, req) -> {
       if (!"bearer my_token".equals(req.headers().get(HttpHeaderNames.AUTHORIZATION))) {
           return HttpResponse.of(HttpStatus.UNAUTHORIZED);
       }
       return delegate.serve(ctx, req);
   });                                              // Return to the VirtualHostBuilder.
 
See Also:
VirtualHostServiceBindingBuilder