public final class VirtualHostBuilder extends Object
VirtualHost.
This class can only be instantiated through the ServerBuilder.defaultVirtualHost() or
ServerBuilder.virtualHost(String) method of the ServerBuilder.
Call and() method and return to ServerBuilder.
ServerBuilder,
Route| Modifier and Type | Method and Description |
|---|---|
VirtualHostBuilder |
accessLogger(Function<VirtualHost,org.slf4j.Logger> mapper)
Sets the access logger mapper of this
VirtualHost. |
VirtualHostBuilder |
accessLogger(org.slf4j.Logger logger)
Sets the
Logger of this VirtualHost, which is used for writing access logs. |
VirtualHostBuilder |
accessLogger(String loggerName)
|
VirtualHostBuilder |
accessLogWriter(AccessLogWriter accessLogWriter,
boolean shutdownOnStop)
Sets the access log writer of this
VirtualHost. |
ServerBuilder |
and()
Returns the parent
ServerBuilder. |
VirtualHostAnnotatedServiceBindingBuilder |
annotatedService()
Returns a new instance of
VirtualHostAnnotatedServiceBindingBuilder to build
AnnotatedHttpService fluently. |
VirtualHostBuilder |
annotatedService(Object service)
Binds the specified annotated service object under the path prefix
"/". |
VirtualHostBuilder |
annotatedService(Object service,
Function<? super HttpService,? extends HttpService> decorator,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the path prefix
"/". |
VirtualHostBuilder |
annotatedService(Object service,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the path prefix
"/". |
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service,
Function<? super HttpService,? extends HttpService> decorator,
Iterable<?> exceptionHandlersAndConverters)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service,
Function<? super HttpService,? extends HttpService> decorator,
Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions,
Iterable<? extends RequestConverterFunction> requestConverterFunctions,
Iterable<? extends ResponseConverterFunction> responseConverterFunctions)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service,
Function<? super HttpService,? extends HttpService> decorator,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service,
Iterable<?> exceptionHandlersAndConverters)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
annotatedService(String pathPrefix,
Object service,
Object... exceptionHandlersAndConverters)
Binds the specified annotated service object under the specified path prefix.
|
VirtualHostBuilder |
contentPreview(int length)
Sets the
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for a request and a response of this VirtualHost. |
VirtualHostBuilder |
contentPreview(int length,
Charset defaultCharset)
Sets the
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for a request and a response of this VirtualHost. |
VirtualHostBuilder |
contentPreviewerFactory(ContentPreviewerFactory factory)
Sets the
ContentPreviewerFactory for a request and a response of this VirtualHost. |
VirtualHostBuilder |
decorator(DecoratingHttpServiceFunction decoratingHttpServiceFunction)
Decorates all
HttpServices with the specified DecoratingHttpServiceFunction. |
VirtualHostBuilder |
decorator(Function<? super HttpService,? extends HttpService> decorator)
Decorates all
HttpServices with the specified decorator. |
VirtualHostBuilder |
decorator(Route route,
DecoratingHttpServiceFunction decoratingHttpServiceFunction)
|
VirtualHostBuilder |
decorator(Route route,
Function<? super HttpService,? extends HttpService> decorator)
|
VirtualHostBuilder |
decorator(String pathPattern,
DecoratingHttpServiceFunction decoratingHttpServiceFunction)
|
VirtualHostBuilder |
decorator(String pathPattern,
Function<? super HttpService,? extends HttpService> decorator)
|
VirtualHostBuilder |
decoratorUnder(String prefix,
DecoratingHttpServiceFunction decoratingHttpServiceFunction)
Decorates
HttpServices under the specified directory. |
VirtualHostBuilder |
decoratorUnder(String prefix,
Function<? super HttpService,? extends HttpService> decorator)
Decorates
HttpServices under the specified directory. |
VirtualHostBuilder |
defaultHostname(String defaultHostname)
Sets the default hostname of this
VirtualHost. |
VirtualHostBuilder |
hostnamePattern(String hostnamePattern)
Sets the hostname pattern of this
VirtualHost. |
VirtualHostBuilder |
maxRequestLength(long maxRequestLength)
Sets the maximum allowed length of the content decoded at the session layer.
|
VirtualHostBuilder |
rejectedRouteHandler(RejectedRouteHandler handler)
Sets the
RejectedRouteHandler which will be invoked when an attempt to bind
an HttpService at a certain Route is rejected. |
VirtualHostBuilder |
requestContentPreviewerFactory(ContentPreviewerFactory factory)
Sets the
ContentPreviewerFactory for a request of this VirtualHost. |
VirtualHostBuilder |
requestTimeout(Duration requestTimeout)
Sets the timeout of a request.
|
VirtualHostBuilder |
requestTimeoutMillis(long requestTimeoutMillis)
Sets the timeout of a request in milliseconds.
|
VirtualHostBuilder |
responseContentPreviewerFactory(ContentPreviewerFactory factory)
Sets the
ContentPreviewerFactory for a response of this VirtualHost. |
VirtualHostServiceBindingBuilder |
route()
Returns a
ServiceBindingBuilder which is for binding an HttpService fluently. |
VirtualHostDecoratingServiceBindingBuilder |
routeDecorator()
Returns a
VirtualHostDecoratingServiceBindingBuilder which is for binding
a decorator fluently. |
VirtualHostBuilder |
service(HttpServiceWithRoutes serviceWithRoutes,
Function<? super HttpService,? extends HttpService>... decorators)
Decorates and binds the specified
HttpServiceWithRoutes at multiple Routes
of the default VirtualHost. |
VirtualHostBuilder |
service(HttpServiceWithRoutes serviceWithRoutes,
Iterable<Function<? super HttpService,? extends HttpService>> decorators)
Decorates and binds the specified
HttpServiceWithRoutes at multiple Routes
of the default VirtualHost. |
VirtualHostBuilder |
service(Route route,
HttpService service)
Binds the specified
HttpService at the specified Route. |
VirtualHostBuilder |
service(String pathPattern,
HttpService service)
Binds the specified
HttpService at the specified path pattern. e.g. |
VirtualHostBuilder |
serviceAt(String pathPattern,
HttpService service)
Deprecated.
Use
service(String, HttpService) instead. |
VirtualHostBuilder |
serviceUnder(String pathPrefix,
HttpService service)
Binds the specified
HttpService under the specified directory. |
VirtualHostBuilder |
tls(File keyCertChainFile,
File keyFile)
Configures SSL or TLS of this
VirtualHost with the specified keyCertChainFile
and cleartext keyFile. |
VirtualHostBuilder |
tls(File keyCertChainFile,
File keyFile,
Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer)
Configures SSL or TLS of this
VirtualHost with the specified keyCertChainFile,
cleartext keyFile and tlsCustomizer. |
VirtualHostBuilder |
tls(File keyCertChainFile,
File keyFile,
String keyPassword)
Configures SSL or TLS of this
VirtualHost with the specified keyCertChainFile,
keyFile and keyPassword. |
VirtualHostBuilder |
tls(File keyCertChainFile,
File keyFile,
String keyPassword,
Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer)
Configures SSL or TLS of this
VirtualHost with the specified keyCertChainFile,
keyFile, keyPassword and tlsCustomizer. |
VirtualHostBuilder |
tls(KeyManagerFactory keyManagerFactory,
Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer)
|
VirtualHostBuilder |
tls(io.netty.handler.ssl.SslContext sslContext)
Configures SSL or TLS of this
VirtualHost with the specified SslContext. |
VirtualHostBuilder |
tlsSelfSigned()
Configures SSL or TLS of this
VirtualHost with an auto-generated self-signed certificate. |
VirtualHostBuilder |
tlsSelfSigned(boolean tlsSelfSigned)
Configures SSL or TLS of this
VirtualHost with an auto-generated self-signed certificate. |
String |
toString() |
VirtualHostBuilder |
verboseResponses(boolean verboseResponses)
Sets whether the verbose response mode is enabled.
|
VirtualHostBuilder |
withRoute(Consumer<VirtualHostServiceBindingBuilder> customizer)
|
public ServerBuilder and()
ServerBuilder.ServerBuilder.public VirtualHostBuilder defaultHostname(String defaultHostname)
VirtualHost.public VirtualHostBuilder hostnamePattern(String hostnamePattern)
VirtualHost.UnsupportedOperationException - if this is the default VirtualHostBuilderpublic VirtualHostBuilder tls(io.netty.handler.ssl.SslContext sslContext) throws SSLException
VirtualHost with the specified SslContext.SSLExceptionpublic VirtualHostBuilder tls(File keyCertChainFile, File keyFile) throws SSLException
VirtualHost with the specified keyCertChainFile
and cleartext keyFile.SSLExceptionpublic VirtualHostBuilder tls(File keyCertChainFile, File keyFile, Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer) throws SSLException
VirtualHost with the specified keyCertChainFile,
cleartext keyFile and tlsCustomizer.SSLExceptionpublic VirtualHostBuilder tls(File keyCertChainFile, File keyFile, @Nullable String keyPassword) throws SSLException
VirtualHost with the specified keyCertChainFile,
keyFile and keyPassword.SSLExceptionpublic VirtualHostBuilder tls(File keyCertChainFile, File keyFile, @Nullable String keyPassword, Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer) throws SSLException
VirtualHost with the specified keyCertChainFile,
keyFile, keyPassword and tlsCustomizer.SSLExceptionpublic VirtualHostBuilder tls(KeyManagerFactory keyManagerFactory, Consumer<io.netty.handler.ssl.SslContextBuilder> tlsCustomizer) throws SSLException
SSLExceptionpublic VirtualHostBuilder tlsSelfSigned()
VirtualHost with an auto-generated self-signed certificate.
Note: You should never use this in production but only for a testing purpose.public VirtualHostBuilder tlsSelfSigned(boolean tlsSelfSigned)
VirtualHost with an auto-generated self-signed certificate.
Note: You should never use this in production but only for a testing purpose.public VirtualHostBuilder withRoute(Consumer<VirtualHostServiceBindingBuilder> customizer)
public VirtualHostServiceBindingBuilder route()
ServiceBindingBuilder which is for binding an HttpService fluently.public VirtualHostDecoratingServiceBindingBuilder routeDecorator()
VirtualHostDecoratingServiceBindingBuilder which is for binding
a decorator fluently.@Deprecated public VirtualHostBuilder serviceAt(String pathPattern, HttpService service)
service(String, HttpService) instead.HttpService at the specified path pattern.public VirtualHostBuilder serviceUnder(String pathPrefix, HttpService service)
HttpService under the specified directory.public VirtualHostBuilder service(String pathPattern, HttpService service)
HttpService at the specified path pattern. e.g.
/login (no path parameters)/users/{userId} (curly-brace style)/list/:productType/by/:ordering (colon style)exact:/foo/bar (exact match)prefix:/files (prefix match)glob:/~*/downloads/** (glob pattern)regex:^/files/(?<filePath>.*)$ (regular expression)IllegalArgumentException - if the specified path pattern is invalidpublic VirtualHostBuilder service(Route route, HttpService service)
HttpService at the specified Route.public VirtualHostBuilder service(HttpServiceWithRoutes serviceWithRoutes, Iterable<Function<? super HttpService,? extends HttpService>> decorators)
HttpServiceWithRoutes at multiple Routes
of the default VirtualHost.serviceWithRoutes - the HttpServiceWithRoutes.decorators - the decorator functions, which will be applied in the order specified.@SafeVarargs public final VirtualHostBuilder service(HttpServiceWithRoutes serviceWithRoutes, Function<? super HttpService,? extends HttpService>... decorators)
HttpServiceWithRoutes at multiple Routes
of the default VirtualHost.serviceWithRoutes - the HttpServiceWithRoutes.decorators - the decorator functions, which will be applied in the order specified.public VirtualHostBuilder annotatedService(Object service)
"/".public VirtualHostBuilder annotatedService(Object service, Object... exceptionHandlersAndConverters)
"/".exceptionHandlersAndConverters - the ExceptionHandlerFunctions,
the RequestConverterFunctions and/or
the ResponseConverterFunctionspublic VirtualHostBuilder annotatedService(Object service, Function<? super HttpService,? extends HttpService> decorator, Object... exceptionHandlersAndConverters)
"/".exceptionHandlersAndConverters - the ExceptionHandlerFunctions,
the RequestConverterFunctions and/or
the ResponseConverterFunctionspublic VirtualHostBuilder annotatedService(String pathPrefix, Object service)
public VirtualHostBuilder annotatedService(String pathPrefix, Object service, Object... exceptionHandlersAndConverters)
exceptionHandlersAndConverters - the ExceptionHandlerFunctions,
the RequestConverterFunctions and/or
the ResponseConverterFunctionspublic VirtualHostBuilder annotatedService(String pathPrefix, Object service, Iterable<?> exceptionHandlersAndConverters)
exceptionHandlersAndConverters - the ExceptionHandlerFunction,
RequestConverterFunction and/or
ResponseConverterFunctionpublic VirtualHostBuilder annotatedService(String pathPrefix, Object service, Function<? super HttpService,? extends HttpService> decorator, Object... exceptionHandlersAndConverters)
exceptionHandlersAndConverters - the ExceptionHandlerFunctions,
the RequestConverterFunctions and/or
the ResponseConverterFunctionspublic VirtualHostBuilder annotatedService(String pathPrefix, Object service, Function<? super HttpService,? extends HttpService> decorator, Iterable<?> exceptionHandlersAndConverters)
exceptionHandlersAndConverters - the ExceptionHandlerFunctions,
the RequestConverterFunctions and/or
the ResponseConverterFunctionspublic VirtualHostBuilder annotatedService(String pathPrefix, Object service, Function<? super HttpService,? extends HttpService> decorator, Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions, Iterable<? extends RequestConverterFunction> requestConverterFunctions, Iterable<? extends ResponseConverterFunction> responseConverterFunctions)
exceptionHandlerFunctions - the ExceptionHandlerFunctionsrequestConverterFunctions - the RequestConverterFunctionsresponseConverterFunctions - the ResponseConverterFunctionspublic VirtualHostAnnotatedServiceBindingBuilder annotatedService()
VirtualHostAnnotatedServiceBindingBuilder to build
AnnotatedHttpService fluently.public VirtualHostBuilder decorator(Function<? super HttpService,? extends HttpService> decorator)
HttpServices with the specified decorator.decorator - the Function that decorates HttpServicespublic VirtualHostBuilder decorator(DecoratingHttpServiceFunction decoratingHttpServiceFunction)
HttpServices with the specified DecoratingHttpServiceFunction.decoratingHttpServiceFunction - the DecoratingHttpServiceFunction that decorates
HttpServicespublic VirtualHostBuilder decorator(String pathPattern, DecoratingHttpServiceFunction decoratingHttpServiceFunction)
decoratingHttpServiceFunction - the DecoratingHttpServiceFunction that decorates
HttpServicespublic VirtualHostBuilder decorator(String pathPattern, Function<? super HttpService,? extends HttpService> decorator)
public VirtualHostBuilder decorator(Route route, Function<? super HttpService,? extends HttpService> decorator)
route - the route being decorateddecorator - the Function that decorates HttpServicepublic VirtualHostBuilder decorator(Route route, DecoratingHttpServiceFunction decoratingHttpServiceFunction)
route - the route being decorateddecoratingHttpServiceFunction - the DecoratingHttpServiceFunction that decorates
HttpServicespublic VirtualHostBuilder decoratorUnder(String prefix, Function<? super HttpService,? extends HttpService> decorator)
HttpServices under the specified directory.public VirtualHostBuilder decoratorUnder(String prefix, DecoratingHttpServiceFunction decoratingHttpServiceFunction)
HttpServices under the specified directory.decoratingHttpServiceFunction - the DecoratingHttpServiceFunction that decorates
HttpServicespublic VirtualHostBuilder accessLogger(Function<VirtualHost,org.slf4j.Logger> mapper)
VirtualHost.public VirtualHostBuilder accessLogger(org.slf4j.Logger logger)
Logger of this VirtualHost, which is used for writing access logs.public VirtualHostBuilder accessLogger(String loggerName)
public VirtualHostBuilder rejectedRouteHandler(RejectedRouteHandler handler)
RejectedRouteHandler which will be invoked when an attempt to bind
an HttpService at a certain Route is rejected. If not set,
the RejectedRouteHandler set via
ServerBuilder.rejectedRouteHandler(RejectedRouteHandler) is used.public VirtualHostBuilder requestTimeout(Duration requestTimeout)
ServerBuilder.requestTimeoutMillis(long) is used.requestTimeout - the timeout. 0 disables the timeout.public VirtualHostBuilder requestTimeoutMillis(long requestTimeoutMillis)
ServerBuilder.requestTimeoutMillis(long) is used.requestTimeoutMillis - the timeout in milliseconds. 0 disables the timeout.public VirtualHostBuilder maxRequestLength(long maxRequestLength)
ServerBuilder.maxRequestLength(long) is used.maxRequestLength - the maximum allowed length. 0 disables the length limit.public VirtualHostBuilder verboseResponses(boolean verboseResponses)
ServerBuilder.verboseResponses(boolean) is used.public VirtualHostBuilder requestContentPreviewerFactory(ContentPreviewerFactory factory)
ContentPreviewerFactory for a request of this VirtualHost. If not set,
the ContentPreviewerFactory ser via
ServerBuilder.requestContentPreviewerFactory(ContentPreviewerFactory) is used.public VirtualHostBuilder responseContentPreviewerFactory(ContentPreviewerFactory factory)
ContentPreviewerFactory for a response of this VirtualHost. If not set,
the ContentPreviewerFactory set via
ServerBuilder.responseContentPreviewerFactory(ContentPreviewerFactory) is used.public VirtualHostBuilder contentPreview(int length)
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for a request and a response of this VirtualHost.
The previewer is enabled only if the content type of a 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 VirtualHostBuilder contentPreview(int length, Charset defaultCharset)
ContentPreviewerFactory for creating a ContentPreviewer which produces the
preview with the maximum length limit for a request and a response of this VirtualHost.
The previewer is enabled only if the content type of a 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 VirtualHostBuilder contentPreviewerFactory(ContentPreviewerFactory factory)
ContentPreviewerFactory for a request and a response of this VirtualHost.public VirtualHostBuilder accessLogWriter(AccessLogWriter accessLogWriter, boolean shutdownOnStop)
VirtualHost. If not set, the AccessLogWriter set via
ServerBuilder.accessLogWriter(AccessLogWriter, boolean) is used.shutdownOnStop - whether to shut down the AccessLogWriter when the Server stopsCopyright © 2020 LeanCloud. All rights reserved.