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 = 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.
VirtualHostServiceBindingBuilder| Modifier and Type | Method and Description |
|---|---|
VirtualHostBuilder |
build(DecoratingHttpServiceFunction decoratingHttpServiceFunction)
Sets the
DecoratingHttpServiceFunction and returns VirtualHostBuilder that this
VirtualHostDecoratingServiceBindingBuilder was created from. |
VirtualHostBuilder |
build(Function<? super HttpService,? extends HttpService> decorator)
Sets the
decorator and returns VirtualHostBuilder that this
VirtualHostDecoratingServiceBindingBuilder was created from. |
VirtualHostDecoratingServiceBindingBuilder |
connect(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.CONNECT requests. |
VirtualHostDecoratingServiceBindingBuilder |
consumes(Iterable<MediaType> consumeTypes)
Sets
MediaTypes that an HttpService will consume. |
VirtualHostDecoratingServiceBindingBuilder |
consumes(MediaType... consumeTypes)
Sets
MediaTypes that an HttpService will consume. |
VirtualHostDecoratingServiceBindingBuilder |
delete(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.DELETE requests. |
VirtualHostDecoratingServiceBindingBuilder |
get(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.GET requests. |
VirtualHostDecoratingServiceBindingBuilder |
head(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.HEAD requests. |
com.linecorp.armeria.server.AbstractBindingBuilder |
matchesHeaders(CharSequence headerName,
Predicate<? super String> valuePredicate)
Sets the
Route to accept a request when the specified valuePredicate evaluates
true with the value of the specified headerName header. |
com.linecorp.armeria.server.AbstractBindingBuilder |
matchesHeaders(Iterable<String> headerPredicates)
Sets the
Route to accept a request if it matches all the specified predicates for
HttpHeaders. |
com.linecorp.armeria.server.AbstractBindingBuilder |
matchesHeaders(String... headerPredicates)
Sets the
Route to accept a request if it matches all the specified predicates for
HttpHeaders. |
com.linecorp.armeria.server.AbstractBindingBuilder |
matchesParams(Iterable<String> paramPredicates)
Sets the
Route to accept a request if it matches all the specified predicates for
HTTP parameters. |
com.linecorp.armeria.server.AbstractBindingBuilder |
matchesParams(String... paramPredicates)
Sets the
Route to accept a request if it matches all the specified predicates for
HTTP parameters. |
com.linecorp.armeria.server.AbstractBindingBuilder |
matchesParams(String paramName,
Predicate<? super String> valuePredicate)
Sets the
Route to accept a request when the specified valuePredicate evaluates
true with the value of the specified paramName parameter. |
VirtualHostDecoratingServiceBindingBuilder |
methods(HttpMethod... methods)
Sets the
HttpMethods that an HttpService will support. |
VirtualHostDecoratingServiceBindingBuilder |
methods(Iterable<HttpMethod> methods)
Sets the
HttpMethods that an HttpService will support. |
VirtualHostDecoratingServiceBindingBuilder |
options(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.OPTIONS requests. |
VirtualHostDecoratingServiceBindingBuilder |
patch(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.PATCH requests. |
VirtualHostDecoratingServiceBindingBuilder |
path(String pathPattern)
Sets the path pattern that an
HttpService will be bound to. |
VirtualHostDecoratingServiceBindingBuilder |
pathPrefix(String prefix)
Sets the specified prefix which is a directory that an
HttpService will be bound under. |
VirtualHostDecoratingServiceBindingBuilder |
pathUnder(String prefix)
Deprecated.
|
VirtualHostDecoratingServiceBindingBuilder |
post(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.POST requests. |
VirtualHostDecoratingServiceBindingBuilder |
produces(Iterable<MediaType> produceTypes)
Sets
MediaTypes that an HttpService will produce to be used in
content negotiation. |
VirtualHostDecoratingServiceBindingBuilder |
produces(MediaType... produceTypes)
Sets
MediaTypes that an HttpService will produce to be used in
content negotiation. |
VirtualHostDecoratingServiceBindingBuilder |
put(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.PUT requests. |
VirtualHostDecoratingServiceBindingBuilder |
trace(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.TRACE requests. |
public 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)
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
HttpServicepublic com.linecorp.armeria.server.AbstractBindingBuilder matchesParams(String... paramPredicates)
Route to accept a request if it matches all the specified predicates for
HTTP parameters. The predicate can be one of the following forms:
some-param=some-value which means that the request must have a
some-param=some-value parametersome-param!=some-value which means that the request must not have a
some-param=some-value parametersome-param which means that the request must contain a some-param parameter!some-param which means that the request must not contain a some-param
parameterNote that these predicates can be evaluated only with the query string of the request URI. Also note that each predicate will be evaluated with the decoded value of HTTP parameters, so do not use percent-encoded value in the predicate.
MatchesParampublic com.linecorp.armeria.server.AbstractBindingBuilder matchesParams(Iterable<String> paramPredicates)
Route to accept a request if it matches all the specified predicates for
HTTP parameters. The predicate can be one of the following forms:
some-param=some-value which means that the request must have a
some-param=some-value parametersome-param!=some-value which means that the request must not have a
some-param=some-value parametersome-param which means that the request must contain a some-param parameter!some-param which means that the request must not contain a some-param
parameterNote that these predicates can be evaluated only with the query string of the request URI. Also note that each predicate will be evaluated with the decoded value of HTTP parameters, so do not use percent-encoded value in the predicate.
MatchesParampublic com.linecorp.armeria.server.AbstractBindingBuilder matchesParams(String paramName, Predicate<? super String> valuePredicate)
Route to accept a request when the specified valuePredicate evaluates
true with the value of the specified paramName parameter.public com.linecorp.armeria.server.AbstractBindingBuilder matchesHeaders(String... headerPredicates)
Route to accept a request if it matches all the specified predicates for
HttpHeaders. The predicate can be one of the following forms:
some-header=some-value which means that the request must have a
some-header: some-value headersome-header!=some-value which means that the request must not have a
some-header: some-value headersome-header which means that the request must contain a some-header header!some-header which means that the request must not contain a some-header
headerMatchesHeaderpublic com.linecorp.armeria.server.AbstractBindingBuilder matchesHeaders(Iterable<String> headerPredicates)
Route to accept a request if it matches all the specified predicates for
HttpHeaders. The predicate can be one of the following forms:
some-header=some-value which means that the request must have a
some-header: some-value headersome-header!=some-value which means that the request must not have a
some-header: some-value an headersome-header which means that the request must contain a some-header header!some-header which means that the request must not contain a some-header
headerMatchesHeaderpublic com.linecorp.armeria.server.AbstractBindingBuilder matchesHeaders(CharSequence headerName, Predicate<? super String> valuePredicate)
Route to accept a request when the specified valuePredicate evaluates
true with the value of the specified headerName header.Copyright © 2020 LeanCloud. All rights reserved.