public final class VirtualHostDecoratingServiceBindingBuilder extends Object
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 = new ServerBuilder();
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.
VirtualHostServiceBindingBuilderpublic VirtualHostDecoratingServiceBindingBuilder path(String pathPattern)
HttpService will be bound to.
Please refer to the Path patterns
in order to learn how to specify a path pattern.@Deprecated public VirtualHostDecoratingServiceBindingBuilder pathUnder(String prefix)
pathPrefix(String).HttpService will be bound under.
pathUnder("/my/path") is identical to path("prefix:/my/path").public VirtualHostDecoratingServiceBindingBuilder pathPrefix(String prefix)
HttpService will be bound under.
pathPrefix("/my/path") is identical to path("prefix:/my/path").public VirtualHostDecoratingServiceBindingBuilder methods(HttpMethod... methods)
HttpMethods that an HttpService will support. If not set,
HttpMethod.knownMethods()s are set.path(String),
pathPrefix(String)public VirtualHostDecoratingServiceBindingBuilder methods(Iterable<HttpMethod> methods)
HttpMethods that an HttpService will support. If not set,
HttpMethod.knownMethods()s are set.path(String),
pathPrefix(String)public VirtualHostDecoratingServiceBindingBuilder get(String pathPattern)
HttpService will be bound to, only supporting
HttpMethod.GET requests.
Please refer to the Path patterns
in order to learn how to specify a path pattern.public VirtualHostDecoratingServiceBindingBuilder post(String pathPattern)
HttpService will be bound to, only supporting
HttpMethod.POST requests.
Please refer to the Path patterns
in order to learn how to specify a path pattern.public VirtualHostDecoratingServiceBindingBuilder put(String pathPattern)
HttpService will be bound to, only supporting
HttpMethod.PUT requests.
Please refer to the Path patterns
in order to learn how to specify a path pattern.public VirtualHostDecoratingServiceBindingBuilder patch(String pathPattern)
HttpService will be bound to, only supporting
HttpMethod.PATCH requests.
Please refer to the Path patterns
in order to learn how to specify a path pattern.public VirtualHostDecoratingServiceBindingBuilder delete(String pathPattern)
HttpService will be bound to, only supporting
HttpMethod.DELETE requests.
Please refer to the Path patterns
in order to learn how to specify a path pattern.public VirtualHostDecoratingServiceBindingBuilder options(String pathPattern)
HttpService will be bound to, only supporting
HttpMethod.OPTIONS requests.
Please refer to the Path patterns
in order to learn how to specify a path pattern.public VirtualHostDecoratingServiceBindingBuilder head(String pathPattern)
HttpService will be bound to, only supporting
HttpMethod.HEAD requests.
Please refer to the Path patterns
in order to learn how to specify a path pattern.public VirtualHostDecoratingServiceBindingBuilder trace(String pathPattern)
HttpService will be bound to, only supporting
HttpMethod.TRACE requests.
Please refer to the Path patterns
in order to learn how to specify a path pattern.public VirtualHostDecoratingServiceBindingBuilder connect(String pathPattern)
HttpService will be bound to, only supporting
HttpMethod.CONNECT requests.
Please refer to the Path patterns
in order to learn how to specify a path pattern.public VirtualHostDecoratingServiceBindingBuilder consumes(MediaType... consumeTypes)
MediaTypes that an HttpService will consume. If not set, the HttpService
will accept all media types.public VirtualHostDecoratingServiceBindingBuilder consumes(Iterable<MediaType> consumeTypes)
MediaTypes that an HttpService will consume. If not set, the HttpService
will accept all media types.public VirtualHostDecoratingServiceBindingBuilder produces(MediaType... produceTypes)
MediaTypes that an HttpService will produce to be used in
content negotiation. See Accept header
for more information.public VirtualHostDecoratingServiceBindingBuilder produces(Iterable<MediaType> produceTypes)
MediaTypes that an HttpService will produce to be used in
content negotiation. See Accept header
for more information.public VirtualHostBuilder build(Function<? super HttpService,? extends HttpService> decorator)
decorator and returns VirtualHostBuilder that this
VirtualHostDecoratingServiceBindingBuilder was created from.decorator - the Function that decorates HttpServicepublic VirtualHostBuilder build(DecoratingHttpServiceFunction decoratingHttpServiceFunction)
DecoratingHttpServiceFunction and returns VirtualHostBuilder that this
VirtualHostDecoratingServiceBindingBuilder was created from.decoratingHttpServiceFunction - the DecoratingHttpServiceFunction that decorates
HttpServiceCopyright © 2020 LeanCloud. All rights reserved.