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 = Server.builder();
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. |
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. |
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
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.