public final class VirtualHostServiceBindingBuilder extends Object
HttpService fluently. This class can be instantiated through
VirtualHostBuilder.route(). You can also configure an HttpService using
VirtualHostBuilder.withRoute(Consumer).
Call build(HttpService) to build the HttpService and return to the
VirtualHostBuilder.
ServerBuilder sb = Server.builder();
sb.virtualHost("example.com")
.route() // Configure the first service in "example.com".
.post("/foo/bar")
.consumes(JSON, PLAIN_TEXT_UTF_8)
.produces(JSON_UTF_8)
.requestTimeoutMillis(5000)
.maxRequestLength(8192)
.verboseResponses(true)
.contentPreview(500)
.build((ctx, req) -> HttpResponse.of(OK)); // Return to the VirtualHostBuilder.
sb.virtualHost("example2.com") // Configure the second service "example2.com".
.withRoute(builder -> builder.path("/baz")
.methods(HttpMethod.GET, HttpMethod.POST)
.build((ctx, req) -> HttpResponse.of(OK)));
ServiceBindingBuilder| Modifier and Type | Method and Description |
|---|---|
VirtualHostServiceBindingBuilder |
accessLogFormat(String accessLogFormat)
Sets the format of this
HttpService's access log. |
VirtualHostServiceBindingBuilder |
accessLogWriter(AccessLogWriter accessLogWriter,
boolean shutdownOnStop)
Sets the access log writer of this
HttpService. |
VirtualHostBuilder |
build(HttpService service)
Sets the
HttpService and returns the VirtualHostBuilder that this
VirtualHostServiceBindingBuilder was created from. |
VirtualHostServiceBindingBuilder |
connect(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.CONNECT requests. |
VirtualHostServiceBindingBuilder |
consumes(Iterable<MediaType> consumeTypes)
Sets
MediaTypes that an HttpService will consume. |
VirtualHostServiceBindingBuilder |
consumes(MediaType... consumeTypes)
Sets
MediaTypes that an HttpService will consume. |
VirtualHostServiceBindingBuilder |
contentPreview(int length)
Sets the
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for an HTTP request/response of the HttpService. |
VirtualHostServiceBindingBuilder |
contentPreview(int length,
Charset defaultCharset)
Sets the
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for an HTTP request/response of an HttpService. |
VirtualHostServiceBindingBuilder |
contentPreviewerFactory(ContentPreviewerFactory factory)
Sets the
ContentPreviewerFactory for an HTTP request/response of an HttpService. |
VirtualHostServiceBindingBuilder |
decorator(Function<? super HttpService,? extends HttpService> decorator)
Decorates an
HttpService with the specified decorator. |
VirtualHostServiceBindingBuilder |
delete(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.DELETE requests. |
VirtualHostServiceBindingBuilder |
get(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.GET requests. |
VirtualHostServiceBindingBuilder |
head(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.HEAD requests. |
VirtualHostServiceBindingBuilder |
maxRequestLength(long maxRequestLength)
Sets the maximum allowed length of an HTTP request.
|
VirtualHostServiceBindingBuilder |
methods(HttpMethod... methods)
Sets the
HttpMethods that an HttpService will support. |
VirtualHostServiceBindingBuilder |
methods(Iterable<HttpMethod> methods)
Sets the
HttpMethods that an HttpService will support. |
VirtualHostServiceBindingBuilder |
options(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.OPTIONS requests. |
VirtualHostServiceBindingBuilder |
patch(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.PATCH requests. |
VirtualHostServiceBindingBuilder |
path(String pathPattern)
Sets the path pattern that an
HttpService will be bound to. |
VirtualHostServiceBindingBuilder |
pathPrefix(String prefix)
Sets the specified prefix which is a directory that an
HttpService will be bound under. |
VirtualHostServiceBindingBuilder |
pathUnder(String prefix)
Deprecated.
Use
pathPrefix(String). |
VirtualHostServiceBindingBuilder |
post(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.POST requests. |
VirtualHostServiceBindingBuilder |
produces(Iterable<MediaType> produceTypes)
Sets
MediaTypes that an HttpService will produce to be used in
content negotiation. |
VirtualHostServiceBindingBuilder |
produces(MediaType... produceTypes)
Sets
MediaTypes that an HttpService will produce to be used in
content negotiation. |
VirtualHostServiceBindingBuilder |
put(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.PUT requests. |
VirtualHostServiceBindingBuilder |
requestContentPreviewerFactory(ContentPreviewerFactory factory)
Sets the
ContentPreviewerFactory for an HTTP request of an HttpService. |
VirtualHostServiceBindingBuilder |
requestTimeout(Duration requestTimeout)
Sets the timeout of an HTTP request.
|
VirtualHostServiceBindingBuilder |
requestTimeoutMillis(long requestTimeoutMillis)
Sets the timeout of an HTTP request in milliseconds.
|
VirtualHostServiceBindingBuilder |
responseContentPreviewerFactory(ContentPreviewerFactory factory)
Sets the
ContentPreviewerFactory for an HTTP response of an HttpService. |
VirtualHostServiceBindingBuilder |
trace(String pathPattern)
Sets the path pattern that an
HttpService will be bound to, only supporting
HttpMethod.TRACE requests. |
VirtualHostServiceBindingBuilder |
verboseResponses(boolean verboseResponses)
Sets whether the verbose response mode is enabled.
|
public VirtualHostServiceBindingBuilder 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 VirtualHostServiceBindingBuilder pathUnder(String prefix)
pathPrefix(String).HttpService will be bound under.
pathUnder("/my/path") is identical to path("prefix:/my/path").public VirtualHostServiceBindingBuilder pathPrefix(String prefix)
HttpService will be bound under.
pathPrefix("/my/path") is identical to path("prefix:/my/path").public VirtualHostServiceBindingBuilder methods(HttpMethod... methods)
HttpMethods that an HttpService will support. If not set,
HttpMethod.knownMethods()s are set.path(String),
pathPrefix(String)public VirtualHostServiceBindingBuilder methods(Iterable<HttpMethod> methods)
HttpMethods that an HttpService will support. If not set,
HttpMethod.knownMethods()s are set.path(String),
pathPrefix(String)public VirtualHostServiceBindingBuilder 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 VirtualHostServiceBindingBuilder 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 VirtualHostServiceBindingBuilder 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 VirtualHostServiceBindingBuilder 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 VirtualHostServiceBindingBuilder 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 VirtualHostServiceBindingBuilder 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 VirtualHostServiceBindingBuilder 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 VirtualHostServiceBindingBuilder 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 VirtualHostServiceBindingBuilder 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 VirtualHostServiceBindingBuilder consumes(MediaType... consumeTypes)
MediaTypes that an HttpService will consume. If not set, the HttpService
will accept all media types.public VirtualHostServiceBindingBuilder consumes(Iterable<MediaType> consumeTypes)
MediaTypes that an HttpService will consume. If not set, the HttpService
will accept all media types.public VirtualHostServiceBindingBuilder produces(MediaType... produceTypes)
MediaTypes that an HttpService will produce to be used in
content negotiation. See Accept header
for more information.public VirtualHostServiceBindingBuilder produces(Iterable<MediaType> produceTypes)
MediaTypes that an HttpService will produce to be used in
content negotiation. See Accept header
for more information.public VirtualHostServiceBindingBuilder requestTimeout(Duration requestTimeout)
VirtualHost.requestTimeoutMillis() is used.requestTimeout - the timeout. 0 disables the timeout.public VirtualHostServiceBindingBuilder requestTimeoutMillis(long requestTimeoutMillis)
VirtualHost.requestTimeoutMillis() is used.requestTimeoutMillis - the timeout in milliseconds. 0 disables the timeout.public VirtualHostServiceBindingBuilder maxRequestLength(long maxRequestLength)
VirtualHost.maxRequestLength() is used.maxRequestLength - the maximum allowed length. 0 disables the length limit.public VirtualHostServiceBindingBuilder verboseResponses(boolean verboseResponses)
VirtualHostBuilder.verboseResponses(boolean) is used.public VirtualHostServiceBindingBuilder requestContentPreviewerFactory(ContentPreviewerFactory factory)
ContentPreviewerFactory for an HTTP request of an HttpService.
If not set, the ContentPreviewerFactory set via
VirtualHost.requestContentPreviewerFactory() is used.public VirtualHostServiceBindingBuilder responseContentPreviewerFactory(ContentPreviewerFactory factory)
ContentPreviewerFactory for an HTTP response of an HttpService.
If not set, the ContentPreviewerFactory set via
VirtualHost.responseContentPreviewerFactory() is used.public VirtualHostServiceBindingBuilder contentPreview(int length)
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for an HTTP request/response of the HttpService.
The previewer is enabled only if the content type of an HTTP request/response meets
any of the following conditions:
text/* or application/x-www-form-urlencoded"xml" or "json""+xml" or "+json"length - the maximum length of the preview.public VirtualHostServiceBindingBuilder contentPreview(int length, Charset defaultCharset)
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for an HTTP request/response of an HttpService.
The previewer is enabled only if the content type of an HTTP request/response meets any of
the following conditions:
text/* or application/x-www-form-urlencoded"xml" or "json""+xml" or "+json"length - the maximum length of the previewdefaultCharset - the default charset used when a charset is not specified in the
"content-type" headerpublic VirtualHostServiceBindingBuilder contentPreviewerFactory(ContentPreviewerFactory factory)
ContentPreviewerFactory for an HTTP request/response of an HttpService.public VirtualHostServiceBindingBuilder accessLogFormat(String accessLogFormat)
HttpService's access log. The specified accessLogFormat would be
parsed by AccessLogWriter.custom(String).public VirtualHostServiceBindingBuilder accessLogWriter(AccessLogWriter accessLogWriter, boolean shutdownOnStop)
HttpService. If not set, the AccessLogWriter set via
VirtualHost.accessLogWriter() is used.shutdownOnStop - whether to shut down the AccessLogWriter when the Server stopspublic VirtualHostServiceBindingBuilder decorator(Function<? super HttpService,? extends HttpService> decorator)
HttpService with the specified decorator.decorator - the Function that decorates the HttpServicepublic VirtualHostBuilder build(HttpService service)
HttpService and returns the VirtualHostBuilder that this
VirtualHostServiceBindingBuilder was created from.IllegalStateException - if the path that the HttpService will be bound to is not specifiedCopyright © 2020 LeanCloud. All rights reserved.