Class VirtualHostBuilder
- All Implemented Interfaces:
TlsSetters
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
.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaccessLogger
(String loggerName) accessLogger
(Function<? super VirtualHost, ? extends Logger> mapper) Sets the access logger mapper of thisVirtualHost
.accessLogger
(Logger logger) Sets theLogger
of thisVirtualHost
, which is used for writing access logs.accessLogWriter
(AccessLogWriter accessLogWriter, boolean shutdownOnStop) Sets the access log writer of thisVirtualHost
.addHeader
(CharSequence name, Object value) Adds the default HTTP header for anHttpResponse
served by thisVirtualHost
.addHeaders
(Iterable<? extends Map.Entry<? extends CharSequence, ?>> defaultHeaders) Adds the default HTTP headers for anHttpResponse
served by thisVirtualHost
.and()
Returns the parentServerBuilder
.Returns a new instance ofVirtualHostAnnotatedServiceBindingBuilder
to build an annotated service fluently.annotatedService
(Object service) Binds the specified annotated service object under the path prefix"/"
.annotatedService
(Object service, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the path prefix"/"
.annotatedService
(Object service, Function<? super HttpService, ? extends HttpService> decorator, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the path prefix"/"
.annotatedService
(String pathPrefix, Object service) Binds the specified annotated service object under the specified path prefix.annotatedService
(String pathPrefix, Object service, Iterable<?> exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.annotatedService
(String pathPrefix, Object service, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.annotatedService
(String pathPrefix, Object service, Function<? super HttpService, ? extends HttpService> decorator, Iterable<?> exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.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.annotatedService
(String pathPrefix, Object service, Function<? super HttpService, ? extends HttpService> decorator, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.annotatedServiceExtensions
(Iterable<? extends RequestConverterFunction> requestConverterFunctions, Iterable<? extends ResponseConverterFunction> responseConverterFunctions, Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions) Sets theRequestConverterFunction
s,ResponseConverterFunction
andExceptionHandlerFunction
s for creating anAnnotatedServiceExtensions
.baseContextPath
(String baseContextPath) Sets the base context path for thisVirtualHost
.blockingTaskExecutor
(int numThreads) Uses a newly createdBlockingTaskExecutor
with the specified number of threads dedicated to the execution of blocking tasks or invocations.blockingTaskExecutor
(BlockingTaskExecutor blockingTaskExecutor, boolean shutdownOnStop) Sets theBlockingTaskExecutor
dedicated to the execution of blocking tasks or invocations.blockingTaskExecutor
(ScheduledExecutorService blockingTaskExecutor, boolean shutdownOnStop) Sets theScheduledExecutorService
dedicated to the execution of blocking tasks or invocations.contextHook
(Supplier<? extends AutoCloseable> contextHook) Sets theAutoCloseable
which will be called whenever thisRequestContext
is popped from theRequestContextStorage
.contextPath
(Iterable<String> contextPaths) Returns aVirtualHostContextPathServicesBuilder
which bindsHttpService
s under the specified context paths.contextPath
(String... contextPaths) Returns aVirtualHostContextPathServicesBuilder
which bindsHttpService
s under the specified context paths.decorator
(DecoratingHttpServiceFunction decoratingHttpServiceFunction) Decorates allHttpService
s with the specifiedDecoratingHttpServiceFunction
.decorator
(Route route, DecoratingHttpServiceFunction decoratingHttpServiceFunction) decorator
(Route route, Function<? super HttpService, ? extends HttpService> decorator) decorator
(String pathPattern, DecoratingHttpServiceFunction decoratingHttpServiceFunction) decorator
(String pathPattern, Function<? super HttpService, ? extends HttpService> decorator) decorator
(Function<? super HttpService, ? extends HttpService> decorator) Decorates allHttpService
s with the specifieddecorator
.decoratorUnder
(String prefix, DecoratingHttpServiceFunction decoratingHttpServiceFunction) DecoratesHttpService
s under the specified directory.decoratorUnder
(String prefix, Function<? super HttpService, ? extends HttpService> decorator) DecoratesHttpService
s under the specified directory.defaultHostname
(String defaultHostname) Sets the default hostname of thisVirtualHost
.defaultLogName
(String defaultLogName) Sets the default value of theRequestOnlyLog.name()
property which is used when no name was set viaRequestLogBuilder.name(String, String)
.defaultServiceNaming
(ServiceNaming defaultServiceNaming) Sets the default naming rule for the name of services.errorHandler
(ServiceErrorHandler errorHandler) Adds theServiceErrorHandler
that handles exceptions thrown in this virtual host.hostnamePattern
(String hostnamePattern) Deprecated.maxRequestLength
(long maxRequestLength) Sets the maximum allowed length of the content decoded at the session layer.multipartRemovalStrategy
(MultipartRemovalStrategy removalStrategy) Sets theMultipartRemovalStrategy
that determines when to remove temporary files created for multipart requests.multipartUploadsLocation
(Path multipartUploadsLocation) Sets thePath
for storing the files uploaded frommultipart/form-data
requests.rejectedRouteHandler
(RejectedRouteHandler handler) Sets theRejectedRouteHandler
which will be invoked when an attempt to bind anHttpService
at a certainRoute
is rejected.requestAutoAbortDelay
(Duration delay) Sets the amount of time to wait before aborting anHttpRequest
when its correspondingHttpResponse
is complete.requestAutoAbortDelayMillis
(long delayMillis) Sets the amount of time in millis to wait before aborting anHttpRequest
when its correspondingHttpResponse
is complete.requestIdGenerator
(Function<? super RoutingContext, ? extends RequestId> requestIdGenerator) requestTimeout
(Duration requestTimeout) Sets the timeout of a request.requestTimeoutMillis
(long requestTimeoutMillis) Sets the timeout of a request in milliseconds.route()
Returns aServiceBindingBuilder
which is for binding anHttpService
fluently.Returns aVirtualHostDecoratingServiceBindingBuilder
which is for binding adecorator
fluently.service
(HttpServiceWithRoutes serviceWithRoutes, Iterable<? extends Function<? super HttpService, ? extends HttpService>> decorators) Decorates and binds the specifiedHttpServiceWithRoutes
at multipleRoute
s.final VirtualHostBuilder
service
(HttpServiceWithRoutes serviceWithRoutes, Function<? super HttpService, ? extends HttpService>... decorators) Decorates and binds the specifiedHttpServiceWithRoutes
at multipleRoute
s.service
(Route route, HttpService service) Binds the specifiedHttpService
at the specifiedRoute
.service
(String pathPattern, HttpService service) Binds the specifiedHttpService
at the specified path pattern. e.g.serviceUnder
(String pathPrefix, HttpService service) Binds the specifiedHttpService
under the specified directory.serviceWorkerGroup
(int numThreads) Uses a newly createdEventLoopGroup
with the specified number of threads dedicated to the execution of services' methods.serviceWorkerGroup
(EventLoopGroup serviceWorkerGroup, boolean shutdownOnStop) Sets theEventLoopGroup
dedicated to the execution of services' methods.setHeader
(CharSequence name, Object value) Sets the default HTTP header for anHttpResponse
served by thisVirtualHost
.setHeaders
(Iterable<? extends Map.Entry<? extends CharSequence, ?>> defaultHeaders) Sets the default HTTP headers for anHttpResponse
served by thisVirtualHost
.successFunction
(SuccessFunction successFunction) Sets theSuccessFunction
to define successful responses.Configures SSL or TLS with the specifiedkeyCertChainFile
and cleartextkeyFile
.Configures SSL or TLS with the specifiedkeyCertChainFile
,keyFile
andkeyPassword
.tls
(InputStream keyCertChainInputStream, InputStream keyInputStream) Configures SSL or TLS with the specifiedkeyCertChainInputStream
and cleartextkeyInputStream
.tls
(InputStream keyCertChainInputStream, InputStream keyInputStream, @Nullable String keyPassword) Configures SSL or TLS of this with the specifiedkeyCertChainInputStream
,keyInputStream
andkeyPassword
.tls
(PrivateKey key, @Nullable String keyPassword, Iterable<? extends X509Certificate> keyCertChain) tls
(PrivateKey key, @Nullable String keyPassword, X509Certificate... keyCertChain) tls
(PrivateKey key, Iterable<? extends X509Certificate> keyCertChain) Configures SSL or TLS with the specified cleartextPrivateKey
andX509Certificate
chain.tls
(PrivateKey key, X509Certificate... keyCertChain) Configures SSL or TLS with the specified cleartextPrivateKey
andX509Certificate
chain.tls
(KeyManagerFactory keyManagerFactory) Configures SSL or TLS with the specifiedKeyManagerFactory
.Deprecated.It's not recommended to enable this option.tlsAllowUnsafeCiphers
(boolean tlsAllowUnsafeCiphers) Deprecated.It's not recommended to enable this option.tlsCustomizer
(Consumer<? super SslContextBuilder> tlsCustomizer) Adds theConsumer
which can arbitrarily configure theSslContextBuilder
that will be applied to the SSL session.tlsEngineType
(TlsEngineType tlsEngineType) TheTlsEngineType
that will be used for processing TLS connections.Configures SSL or TLS of thisVirtualHost
with an auto-generated self-signed certificate.tlsSelfSigned
(boolean tlsSelfSigned) Configures SSL or TLS of thisVirtualHost
with an auto-generated self-signed certificate.verboseResponses
(boolean verboseResponses) Sets whether the verbose response mode is enabled.withRoute
(Consumer<? super VirtualHostServiceBindingBuilder> customizer)
-
Method Details
-
and
Returns the parentServerBuilder
.- Returns:
- serverBuilder the parent
ServerBuilder
.
-
defaultHostname
Sets the default hostname of thisVirtualHost
. -
baseContextPath
Sets the base context path for thisVirtualHost
. Services and decorators added to thisVirtualHost
will be prefixed by the specifiedbaseContextPath
. -
hostnamePattern
Deprecated.prefer specifying the hostnamePattern usingServerBuilder.virtualHost(String)
orServerBuilder.withVirtualHost(String, Consumer)
Sets the hostname pattern of thisVirtualHost
. If the hostname pattern contains a port number such*.example.com:8080
, the returned virtual host will be bound to the8080
port. Otherwise, the virtual host will allow all active ports.- Throws:
UnsupportedOperationException
- if this is the defaultVirtualHostBuilder
-
tls
Description copied from interface:TlsSetters
Configures SSL or TLS with the specifiedkeyCertChainFile
and cleartextkeyFile
.- Specified by:
tls
in interfaceTlsSetters
-
tls
public VirtualHostBuilder tls(File keyCertChainFile, File keyFile, @Nullable @Nullable String keyPassword) Description copied from interface:TlsSetters
Configures SSL or TLS with the specifiedkeyCertChainFile
,keyFile
andkeyPassword
.- Specified by:
tls
in interfaceTlsSetters
-
tls
Description copied from interface:TlsSetters
Configures SSL or TLS with the specifiedkeyCertChainInputStream
and cleartextkeyInputStream
.- Specified by:
tls
in interfaceTlsSetters
-
tls
public VirtualHostBuilder tls(InputStream keyCertChainInputStream, InputStream keyInputStream, @Nullable @Nullable String keyPassword) Description copied from interface:TlsSetters
Configures SSL or TLS of this with the specifiedkeyCertChainInputStream
,keyInputStream
andkeyPassword
.- Specified by:
tls
in interfaceTlsSetters
-
tls
Description copied from interface:TlsSetters
Configures SSL or TLS with the specified cleartextPrivateKey
andX509Certificate
chain.- Specified by:
tls
in interfaceTlsSetters
-
tls
Description copied from interface:TlsSetters
Configures SSL or TLS with the specified cleartextPrivateKey
andX509Certificate
chain.- Specified by:
tls
in interfaceTlsSetters
-
tls
public VirtualHostBuilder tls(PrivateKey key, @Nullable @Nullable String keyPassword, X509Certificate... keyCertChain) Description copied from interface:TlsSetters
- Specified by:
tls
in interfaceTlsSetters
-
tls
public VirtualHostBuilder tls(PrivateKey key, @Nullable @Nullable String keyPassword, Iterable<? extends X509Certificate> keyCertChain) Description copied from interface:TlsSetters
- Specified by:
tls
in interfaceTlsSetters
-
tls
Description copied from interface:TlsSetters
Configures SSL or TLS with the specifiedKeyManagerFactory
.- Specified by:
tls
in interfaceTlsSetters
-
tlsSelfSigned
Configures SSL or TLS of thisVirtualHost
with an auto-generated self-signed certificate. Note: You should never use this in production but only for a testing purpose.- See Also:
-
tlsSelfSigned
Configures SSL or TLS of thisVirtualHost
with an auto-generated self-signed certificate. Note: You should never use this in production but only for a testing purpose.- See Also:
-
tlsCustomizer
Description copied from interface:TlsSetters
Adds theConsumer
which can arbitrarily configure theSslContextBuilder
that will be applied to the SSL session.- Specified by:
tlsCustomizer
in interfaceTlsSetters
-
tlsAllowUnsafeCiphers
Deprecated.It's not recommended to enable this option. Use it only when you have no other way to communicate with an insecure peer than this.Allows the bad cipher suites listed in RFC7540 for TLS handshake.Note that enabling this option increases the security risk of your connection. Use it only when you must communicate with a legacy system that does not support secure cipher suites. See Section 9.2.2, RFC7540 for more information. This option is disabled by default.
-
tlsAllowUnsafeCiphers
Deprecated.It's not recommended to enable this option. Use it only when you have no other way to communicate with an insecure peer than this.Allows the bad cipher suites listed in RFC7540 for TLS handshake.Note that enabling this option increases the security risk of your connection. Use it only when you must communicate with a legacy system that does not support secure cipher suites. See Section 9.2.2, RFC7540 for more information. This option is disabled by default.
- Parameters:
tlsAllowUnsafeCiphers
- Whether to allow the unsafe ciphers
-
tlsEngineType
TheTlsEngineType
that will be used for processing TLS connections. -
contextPath
Returns aVirtualHostContextPathServicesBuilder
which bindsHttpService
s under the specified context paths.- See Also:
-
contextPath
@UnstableApi public VirtualHostContextPathServicesBuilder contextPath(Iterable<String> contextPaths) Returns aVirtualHostContextPathServicesBuilder
which bindsHttpService
s under the specified context paths.- See Also:
-
withRoute
-
route
Returns aServiceBindingBuilder
which is for binding anHttpService
fluently. -
routeDecorator
Returns aVirtualHostDecoratingServiceBindingBuilder
which is for binding adecorator
fluently. The specified decorator(s) is/are executed in reverse order of the insertion. -
serviceUnder
Binds the specifiedHttpService
under the specified directory. If the specifiedHttpService
is anHttpServiceWithRoutes
, thepathPrefix
is added to eachRoute
ofServiceWithRoutes.routes()
. For example, theserviceWithRoutes
in the following code will be bound to ("/foo/bar"
) and ("/foo/baz"
):> HttpServiceWithRoutes serviceWithRoutes = new HttpServiceWithRoutes() { > @Override > public HttpResponse serve(ServiceRequestContext ctx, HttpRequest req) { ... } > > @Override > public Set<Route> routes() { > return Set.of(Route.builder().path("/bar").build(), > Route.builder().path("/baz").build()); > } > }; > > Server.builder() > .serviceUnder("/foo", serviceWithRoutes) > .build();
-
service
Binds the specifiedHttpService
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)
- Throws:
IllegalArgumentException
- if the specified path pattern is invalid
-
service
Binds the specifiedHttpService
at the specifiedRoute
. -
service
public VirtualHostBuilder service(HttpServiceWithRoutes serviceWithRoutes, Iterable<? extends Function<? super HttpService, ? extends HttpService>> decorators) Decorates and binds the specifiedHttpServiceWithRoutes
at multipleRoute
s.- Parameters:
serviceWithRoutes
- theHttpServiceWithRoutes
.decorators
- the decorator functions, which will be applied in the order specified.
-
service
@SafeVarargs public final VirtualHostBuilder service(HttpServiceWithRoutes serviceWithRoutes, Function<? super HttpService, ? extends HttpService>... decorators) Decorates and binds the specifiedHttpServiceWithRoutes
at multipleRoute
s.- Parameters:
serviceWithRoutes
- theHttpServiceWithRoutes
.decorators
- the decorator functions, which will be applied in the order specified.
-
annotatedService
Binds the specified annotated service object under the path prefix"/"
. -
annotatedService
public VirtualHostBuilder annotatedService(Object service, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the path prefix"/"
.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
s, theRequestConverterFunction
s and/or theResponseConverterFunction
s
-
annotatedService
public VirtualHostBuilder annotatedService(Object service, Function<? super HttpService, ? extends HttpService> decorator, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the path prefix"/"
.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
s, theRequestConverterFunction
s and/or theResponseConverterFunction
s
-
annotatedService
Binds the specified annotated service object under the specified path prefix. -
annotatedService
public VirtualHostBuilder annotatedService(String pathPrefix, Object service, Object... exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
s, theRequestConverterFunction
s and/or theResponseConverterFunction
s
-
annotatedService
public VirtualHostBuilder annotatedService(String pathPrefix, Object service, Iterable<?> exceptionHandlersAndConverters) Binds the specified annotated service object under the specified path prefix.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
,RequestConverterFunction
and/orResponseConverterFunction
-
annotatedService
public 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.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
s, theRequestConverterFunction
s and/or theResponseConverterFunction
s
-
annotatedService
public 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.- Parameters:
exceptionHandlersAndConverters
- theExceptionHandlerFunction
s, theRequestConverterFunction
s and/or theResponseConverterFunction
s
-
annotatedService
public 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.- Parameters:
exceptionHandlerFunctions
- theExceptionHandlerFunction
srequestConverterFunctions
- theRequestConverterFunction
sresponseConverterFunctions
- theResponseConverterFunction
s
-
annotatedService
Returns a new instance ofVirtualHostAnnotatedServiceBindingBuilder
to build an annotated service fluently. -
decorator
Decorates allHttpService
s with the specifieddecorator
. The specified decorator(s) is/are executed in reverse order of the insertion.- Parameters:
decorator
- theFunction
that decoratesHttpService
s
-
decorator
Decorates allHttpService
s with the specifiedDecoratingHttpServiceFunction
. The specified decorator(s) is/are executed in reverse order of the insertion.- Parameters:
decoratingHttpServiceFunction
- theDecoratingHttpServiceFunction
that decoratesHttpService
s
-
decorator
public VirtualHostBuilder decorator(String pathPattern, DecoratingHttpServiceFunction decoratingHttpServiceFunction) DecoratesHttpService
s whoseRoute
matches the specifiedpathPattern
. The specified decorator(s) is/are executed in reverse order of the insertion.- Parameters:
decoratingHttpServiceFunction
- theDecoratingHttpServiceFunction
that decoratesHttpService
s
-
decorator
public VirtualHostBuilder decorator(String pathPattern, Function<? super HttpService, ? extends HttpService> decorator) DecoratesHttpService
s whoseRoute
matches the specifiedpathPattern
. The specified decorator(s) is/are executed in reverse order of the insertion. -
decorator
public VirtualHostBuilder decorator(Route route, Function<? super HttpService, ? extends HttpService> decorator) DecoratesHttpService
s whoseRoute
matches the specifiedRoute
. The specified decorator(s) is/are executed in reverse order of the insertion.- Parameters:
route
- the route being decorateddecorator
- theFunction
that decoratesHttpService
-
decorator
public VirtualHostBuilder decorator(Route route, DecoratingHttpServiceFunction decoratingHttpServiceFunction) DecoratesHttpService
s whoseRoute
matches the specifiedRoute
. The specified decorator(s) is/are executed in reverse order of the insertion.- Parameters:
route
- the route being decorateddecoratingHttpServiceFunction
- theDecoratingHttpServiceFunction
that decoratesHttpService
s
-
decoratorUnder
public VirtualHostBuilder decoratorUnder(String prefix, Function<? super HttpService, ? extends HttpService> decorator) DecoratesHttpService
s under the specified directory. The specified decorator(s) is/are executed in reverse order of the insertion. -
decoratorUnder
public VirtualHostBuilder decoratorUnder(String prefix, DecoratingHttpServiceFunction decoratingHttpServiceFunction) DecoratesHttpService
s under the specified directory. The specified decorator(s) is/are executed in reverse order of the insertion.- Parameters:
decoratingHttpServiceFunction
- theDecoratingHttpServiceFunction
that decoratesHttpService
s
-
accessLogger
Sets the access logger mapper of thisVirtualHost
. -
accessLogger
Sets theLogger
of thisVirtualHost
, which is used for writing access logs. -
accessLogger
-
errorHandler
Adds theServiceErrorHandler
that handles exceptions thrown in this virtual host. If multiple handlers are added, the latter is composed with the former usingServiceErrorHandler.orElse(ServiceErrorHandler)
. -
rejectedRouteHandler
Sets theRejectedRouteHandler
which will be invoked when an attempt to bind anHttpService
at a certainRoute
is rejected. If not set, theRejectedRouteHandler
set viaServerBuilder.rejectedRouteHandler(RejectedRouteHandler)
is used. -
addHeader
Adds the default HTTP header for anHttpResponse
served by thisVirtualHost
.Note that the default header could be overridden if the same
HttpHeaderNames
are defined in one of the followings:ServiceRequestContext.additionalResponseHeaders()
- The
ResponseHeaders
of theHttpResponse
ServiceConfigSetters.addHeader(CharSequence, Object)
orServiceConfigSetters.addHeader(CharSequence, Object)
-
addHeaders
@UnstableApi public VirtualHostBuilder addHeaders(Iterable<? extends Map.Entry<? extends CharSequence, ?>> defaultHeaders) Adds the default HTTP headers for anHttpResponse
served by thisVirtualHost
.Note that the default headers could be overridden if the same
HttpHeaderNames
are defined in one of the followings:ServiceRequestContext.additionalResponseHeaders()
- The
ResponseHeaders
of theHttpResponse
ServiceConfigSetters.addHeaders(Iterable)
orServiceConfigSetters.addHeaders(Iterable)
-
setHeader
Sets the default HTTP header for anHttpResponse
served by thisVirtualHost
.Note that the default header could be overridden if the same
HttpHeaderNames
are defined in one of the followings:ServiceRequestContext.additionalResponseHeaders()
- The
ResponseHeaders
of theHttpResponse
ServiceConfigSetters.setHeader(CharSequence, Object)
orServiceConfigSetters.setHeader(CharSequence, Object)
-
setHeaders
@UnstableApi public VirtualHostBuilder setHeaders(Iterable<? extends Map.Entry<? extends CharSequence, ?>> defaultHeaders) Sets the default HTTP headers for anHttpResponse
served by thisVirtualHost
.Note that the default headers could be overridden if the same
HttpHeaderNames
are defined in one of the followings:ServiceRequestContext.additionalResponseHeaders()
- The
ResponseHeaders
of theHttpResponse
ServiceConfigSetters.setHeaders(Iterable)
orServiceConfigSetters.setHeaders(Iterable)
-
requestTimeout
Sets the timeout of a request. If not set, the value set viaServerBuilder.requestTimeoutMillis(long)
is used.- Parameters:
requestTimeout
- the timeout.0
disables the timeout.
-
defaultServiceNaming
Sets the default naming rule for the name of services. If not set, the value set viaServerBuilder.defaultServiceNaming(ServiceNaming)
is used. -
defaultLogName
Sets the default value of theRequestOnlyLog.name()
property which is used when no name was set viaRequestLogBuilder.name(String, String)
.- Parameters:
defaultLogName
- the default log name.
-
requestTimeoutMillis
Sets the timeout of a request in milliseconds. If not set, the value set viaServerBuilder.requestTimeoutMillis(long)
is used.- Parameters:
requestTimeoutMillis
- the timeout in milliseconds.0
disables the timeout.
-
maxRequestLength
Sets the maximum allowed length of the content decoded at the session layer. e.g. the content length of an HTTP request. If not set, the value set viaServerBuilder.maxRequestLength(long)
is used.- Parameters:
maxRequestLength
- the maximum allowed length.0
disables the length limit.
-
verboseResponses
Sets whether the verbose response mode is enabled. When enabled, the server responses will contain the exception type and its full stack trace, which may be useful for debugging while potentially insecure. When disabled, the server responses will not expose such server-side details to the client. If not set, the value set viaServerBuilder.verboseResponses(boolean)
is used. -
accessLogWriter
Sets the access log writer of thisVirtualHost
. If not set, theAccessLogWriter
set viaServerBuilder.accessLogWriter(AccessLogWriter, boolean)
is used.- Parameters:
shutdownOnStop
- whether to shut down theAccessLogWriter
when theServer
stops
-
blockingTaskExecutor
public VirtualHostBuilder blockingTaskExecutor(ScheduledExecutorService blockingTaskExecutor, boolean shutdownOnStop) Sets theScheduledExecutorService
dedicated to the execution of blocking tasks or invocations. If not set, the common pool is used.- Parameters:
shutdownOnStop
- whether to shut down theScheduledExecutorService
when theServer
stops
-
blockingTaskExecutor
public VirtualHostBuilder blockingTaskExecutor(BlockingTaskExecutor blockingTaskExecutor, boolean shutdownOnStop) Sets theBlockingTaskExecutor
dedicated to the execution of blocking tasks or invocations. If not set, the common pool is used.- Parameters:
shutdownOnStop
- whether to shut down theBlockingTaskExecutor
when theServer
stops
-
blockingTaskExecutor
Uses a newly createdBlockingTaskExecutor
with the specified number of threads dedicated to the execution of blocking tasks or invocations. The workerEventLoopGroup
will be shut down when theServer
stops.- Parameters:
numThreads
- the number of threads in the executor
-
successFunction
Sets theSuccessFunction
to define successful responses.MetricCollectingService
andLoggingService
use this function. -
requestAutoAbortDelay
Sets the amount of time to wait before aborting anHttpRequest
when its correspondingHttpResponse
is complete. This may be useful when you want to receive additional data even after closing the response. SpecifyDuration.ZERO
to abort theHttpRequest
immediately. Any negative value will not abort the request automatically. There is no delay by default. -
requestAutoAbortDelayMillis
Sets the amount of time in millis to wait before aborting anHttpRequest
when its correspondingHttpResponse
is complete. This may be useful when you want to receive additional data even after closing the response. Specify0
to abort theHttpRequest
immediately. Any negative value will not abort the request automatically. There is no delay by default. -
multipartUploadsLocation
Sets thePath
for storing the files uploaded frommultipart/form-data
requests.- Parameters:
multipartUploadsLocation
- the path of the directory which stores the files.
-
multipartRemovalStrategy
@UnstableApi public VirtualHostBuilder multipartRemovalStrategy(MultipartRemovalStrategy removalStrategy) Sets theMultipartRemovalStrategy
that determines when to remove temporary files created for multipart requests. If not set,MultipartRemovalStrategy.ON_RESPONSE_COMPLETION
is used by default. -
requestIdGenerator
public VirtualHostBuilder requestIdGenerator(Function<? super RoutingContext, ? extends RequestId> requestIdGenerator) Sets theFunction
which generates aRequestId
. If not set, the value set viaServerBuilder.requestIdGenerator(Function)
is used. -
serviceWorkerGroup
@UnstableApi public VirtualHostBuilder serviceWorkerGroup(EventLoopGroup serviceWorkerGroup, boolean shutdownOnStop) Sets theEventLoopGroup
dedicated to the execution of services' methods. If not set, the work group of the belonging channel is used.- Parameters:
shutdownOnStop
- whether to shut down theEventLoopGroup
when theServer
stops
-
serviceWorkerGroup
Uses a newly createdEventLoopGroup
with the specified number of threads dedicated to the execution of services' methods. The workerEventLoopGroup
will be shut down when theServer
stops.- Parameters:
numThreads
- the number of threads in the executor
-
annotatedServiceExtensions
public VirtualHostBuilder annotatedServiceExtensions(Iterable<? extends RequestConverterFunction> requestConverterFunctions, Iterable<? extends ResponseConverterFunction> responseConverterFunctions, Iterable<? extends ExceptionHandlerFunction> exceptionHandlerFunctions) Sets theRequestConverterFunction
s,ResponseConverterFunction
andExceptionHandlerFunction
s for creating anAnnotatedServiceExtensions
.- Parameters:
requestConverterFunctions
- theRequestConverterFunction
sresponseConverterFunctions
- theResponseConverterFunction
sexceptionHandlerFunctions
- theExceptionHandlerFunction
s
-
contextHook
Sets theAutoCloseable
which will be called whenever thisRequestContext
is popped from theRequestContextStorage
.- Parameters:
contextHook
- theSupplier
that provides theAutoCloseable
-
ServerBuilder.virtualHost(String)
orServerBuilder.withVirtualHost(String, Consumer)