public final class DecoratingServiceBindingBuilder extends Object
decorator with Route fluently.
This class can be instantiated through ServerBuilder.routeDecorator().
Call build(Function) or build(DecoratingHttpServiceFunction)
to build the decorator and return to the ServerBuilder.
ServerBuilder sb = new ServerBuilder();
sb.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 ServerBuilder.
| Modifier and Type | Method and Description |
|---|---|
ServerBuilder |
build(DecoratingHttpServiceFunction decoratingHttpServiceFunction)
Sets the
DecoratingHttpServiceFunction and returns ServerBuilder that this
DecoratingServiceBindingBuilder was created from. |
ServerBuilder |
build(Function<? super HttpService,? extends HttpService> decorator)
Sets the
decorator and returns ServerBuilder that this
DecoratingServiceBindingBuilder was created from. |
DecoratingServiceBindingBuilder |
connect(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.CONNECT requests. |
DecoratingServiceBindingBuilder |
consumes(Iterable<MediaType> consumeTypes)
Sets
MediaTypes that an HttpService will consume. |
DecoratingServiceBindingBuilder |
consumes(MediaType... consumeTypes)
Sets
MediaTypes that an HttpService will consume. |
DecoratingServiceBindingBuilder |
delete(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.DELETE requests. |
DecoratingServiceBindingBuilder |
get(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.GET requests. |
DecoratingServiceBindingBuilder |
head(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.HEAD requests. |
DecoratingServiceBindingBuilder |
methods(HttpMethod... methods)
Sets the
HttpMethods that an HttpService will support. |
DecoratingServiceBindingBuilder |
methods(Iterable<HttpMethod> methods)
Sets the
HttpMethods that an HttpService will support. |
DecoratingServiceBindingBuilder |
options(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.OPTIONS requests. |
DecoratingServiceBindingBuilder |
patch(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.PATCH requests. |
DecoratingServiceBindingBuilder |
path(String pathPattern)
Sets the path pattern that an
HttpService will be bound to. |
DecoratingServiceBindingBuilder |
pathPrefix(String prefix)
Sets the specified prefix which is a directory that an
HttpService will be bound under. |
DecoratingServiceBindingBuilder |
pathUnder(String prefix)
Deprecated.
Use
pathPrefix(String). |
DecoratingServiceBindingBuilder |
post(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.POST requests. |
DecoratingServiceBindingBuilder |
produces(Iterable<MediaType> produceTypes)
Sets
MediaTypes that an HttpService will produce to be used in
content negotiation. |
DecoratingServiceBindingBuilder |
produces(MediaType... produceTypes)
Sets
MediaTypes that an HttpService will produce to be used in
content negotiation. |
DecoratingServiceBindingBuilder |
put(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.PUT requests. |
DecoratingServiceBindingBuilder |
trace(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.TRACE requests. |
public DecoratingServiceBindingBuilder 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 DecoratingServiceBindingBuilder pathUnder(String prefix)
pathPrefix(String).HttpService will be bound under.
pathUnder("/my/path") is identical to path("prefix:/my/path").public DecoratingServiceBindingBuilder pathPrefix(String prefix)
HttpService will be bound under.
pathPrefix("/my/path") is identical to path("prefix:/my/path").public DecoratingServiceBindingBuilder methods(HttpMethod... methods)
HttpMethods that an HttpService will support. If not set,
HttpMethod.knownMethods()s are set.path(String),
pathPrefix(String)public DecoratingServiceBindingBuilder methods(Iterable<HttpMethod> methods)
HttpMethods that an HttpService will support. If not set,
HttpMethod.knownMethods()s are set.path(String),
pathPrefix(String)public DecoratingServiceBindingBuilder 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 DecoratingServiceBindingBuilder 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 DecoratingServiceBindingBuilder 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 DecoratingServiceBindingBuilder 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 DecoratingServiceBindingBuilder 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 DecoratingServiceBindingBuilder 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 DecoratingServiceBindingBuilder 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 DecoratingServiceBindingBuilder 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 DecoratingServiceBindingBuilder 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 DecoratingServiceBindingBuilder consumes(MediaType... consumeTypes)
MediaTypes that an HttpService will consume. If not set, the HttpService
will accept all media types.public DecoratingServiceBindingBuilder consumes(Iterable<MediaType> consumeTypes)
MediaTypes that an HttpService will consume. If not set, the HttpService
will accept all media types.public DecoratingServiceBindingBuilder produces(MediaType... produceTypes)
MediaTypes that an HttpService will produce to be used in
content negotiation. See Accept header
for more information.public DecoratingServiceBindingBuilder produces(Iterable<MediaType> produceTypes)
MediaTypes that an HttpService will produce to be used in
content negotiation. See Accept header
for more information.public ServerBuilder build(Function<? super HttpService,? extends HttpService> decorator)
decorator and returns ServerBuilder that this
DecoratingServiceBindingBuilder was created from.decorator - the Function that decorates HttpServicepublic ServerBuilder build(DecoratingHttpServiceFunction decoratingHttpServiceFunction)
DecoratingHttpServiceFunction and returns ServerBuilder that this
DecoratingServiceBindingBuilder was created from.decoratingHttpServiceFunction - the DecoratingHttpServiceFunction that decorates
HttpServiceCopyright © 2020 LeanCloud. All rights reserved.