- java.lang.Object
-
- io.helidon.webserver.WebServer.Builder
-
- All Implemented Interfaces:
Builder<WebServer>
,MediaContextBuilder<WebServer.Builder>
,ParentingMediaContextBuilder<WebServer.Builder>
,SocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
,Supplier<WebServer>
- Enclosing interface:
- WebServer
public static final class WebServer.Builder extends Object implements Builder<WebServer>, SocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>, ParentingMediaContextBuilder<WebServer.Builder>, MediaContextBuilder<WebServer.Builder>
WebServer builder class provides a convenient way to set up WebServer with multiple server sockets and optional multiple routings.
-
-
Field Summary
-
Fields inherited from interface io.helidon.webserver.SocketConfiguration.SocketConfigurationBuilder
REQUESTED_URI_DISCOVERY_CONFIG_KEY_PREFIX
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description WebServer.Builder
addMediaSupport(MediaSupport mediaSupport)
Adds new instance ofMediaSupport
.WebServer.Builder
addNamedRouting(String name, Routing routing)
Associates a dedicated routing with an additional server socket configuration.WebServer.Builder
addNamedRouting(String name, Supplier<Routing> routingBuilder)
Associates a dedicated routing with an additional server socket configuration.WebServer.Builder
addReader(MessageBodyReader<?> reader)
Registers new reader.WebServer.Builder
addRequestedUriDiscoveryType(SocketConfiguration.RequestedUriDiscoveryType type)
Adds a type of front-end URI discovery Helidon should use for this socket.WebServer.Builder
addSocket(SocketConfiguration config)
Adds an additional named server socket configuration.WebServer.Builder
addSocket(SocketConfiguration socketConfiguration, Routing routing)
Add a named socket and routing.WebServer.Builder
addSocket(String name, SocketConfiguration socketConfiguration)
Deprecated.since 2.0.0, please useaddSocket(SocketConfiguration)
instead, name is now part of socket configurationWebServer.Builder
addSocket(String name, Supplier<SocketConfiguration> socketConfigurationBuilder)
Deprecated.since 2.0.0, please useaddSocket(Supplier)
instead, name is now part of socket configurationWebServer.Builder
addSocket(Supplier<SocketConfiguration> socketConfigurationBuilder)
Adds an additional named server socket configuration builder.WebServer.Builder
addStreamReader(MessageBodyStreamReader<?> streamReader)
Registers new stream reader.WebServer.Builder
addStreamWriter(MessageBodyStreamWriter<?> streamWriter)
Registers new stream writer.WebServer.Builder
addWriter(MessageBodyWriter<?> writer)
Registers new writer.WebServer.Builder
backlog(int backlog)
Configures a maximum length of the queue of incoming connections on the server socket.WebServer.Builder
backpressureBufferSize(long backpressureBufferSize)
Maximum length of the response data sending buffer can keep without flushing.WebServer.Builder
backpressureStrategy(BackpressureStrategy backpressureStrategy)
Sets a backpressure strategy for the server to apply against user provided response upstream.WebServer.Builder
bindAddress(InetAddress bindAddress)
Configures local address where the server listens on with the server socket.WebServer
build()
Builds theWebServer
instance as configured by this builder and its parameters.WebServer.Builder
config(Config config)
Update this server configuration from the config provided.WebServer.Builder
config(ServerConfiguration configuration)
Deprecated.since 2.0.0 - please use methods on this builder, orconfig(io.helidon.config.Config)
insteadWebServer.Builder
config(Supplier<ServerConfiguration> configurationBuilder)
Deprecated.since 2.0.0 - seeconfig(ServerConfiguration)
WebServer.Builder
connectionIdleTimeout(int seconds)
Sets the number of seconds after which an idle connection will be automatically closed by the server.WebServer.Builder
context(Context context)
Configure the application scoped context to be used as a parent for webserver request contexts.WebServer.Builder
continueImmediately(boolean continueImmediately)
When true WebServer answers to expect continue with 100 continue immediately, not waiting for user to actually request the data.WebServer.Builder
defaultSocket(Consumer<SocketConfiguration.Builder> socket)
Configure listener for the default socket.WebServer.Builder
directHandler(DirectHandler handler, DirectHandler.EventType... types)
Provide a custom handler for events that bypass routing.WebServer.Builder
enableCompression(boolean value)
Enable negotiation for gzip/deflate content encodings.WebServer.Builder
experimental(ExperimentalConfiguration experimental)
Configure experimental features.boolean
hasSocket(String socketName)
A method to validate a named socket configuration exists in this builder.WebServer.Builder
maxHeaderSize(int size)
Maximal number of bytes of all header values combined.WebServer.Builder
maxInitialLineLength(int length)
Maximal number of characters in the initial HTTP line.WebServer.Builder
maxPayloadSize(long size)
Set a maximum payload size for a client request.WebServer.Builder
mediaContext(MediaContext mediaContext)
Sets theMediaContext
parent and overrides the existing one.WebServer.Builder
port(int port)
Configures a server port to listen on with the server socket.WebServer.Builder
printFeatureDetails(boolean shouldPrint)
Set totrue
to print detailed feature information on startup.WebServer.Builder
receiveBufferSize(int receiveBufferSize)
Configures proposed value of the TCP receive window that is advertised to the remote peer on the server socket.WebServer.Builder
requestedUriDiscoveryEnabled(boolean enabled)
Sets whether requested URI discovery is enabled for the socket.WebServer.Builder
requestedUriDiscoveryTypes(List<SocketConfiguration.RequestedUriDiscoveryType> types)
Assigns the front-end URI discovery type(s) this socket should use.WebServer.Builder
routing(Routing defaultRouting)
Configure the default routing of this WebServer.WebServer.Builder
routing(Supplier<Routing> defaultRouting)
Configure the default routing of this WebServer.WebServer.Builder
timeout(long amount, TimeUnit unit)
Configures a server socket timeout.WebServer.Builder
tls(WebServerTls webServerTls)
Configures SSL for this socket.WebServer.Builder
tracer(Tracer tracer)
Sets an opentracing.io tracer.WebServer.Builder
tracer(Supplier<? extends Tracer> tracerBuilder)
Sets an opentracing.io tracer.WebServer.Builder
transport(Transport transport)
Configure the transport to be used by this server.WebServer.Builder
trustedProxies(AllowList trustedProxies)
Assigns the settings governing the acceptance and rejection of forwarded headers from incoming requests to this socket.WebServer.Builder
update(Consumer<WebServer.Builder> updateFunction)
A helper method to support fluentAPI when invoking another method.WebServer.Builder
workersCount(int workers)
Sets a count of threads in pool used to process HTTP requests.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.helidon.media.common.MediaContextBuilder
addMediaSupport, addReader, addStreamReader, addStreamWriter, addWriter
-
Methods inherited from interface io.helidon.media.common.ParentingMediaContextBuilder
mediaContext
-
Methods inherited from interface io.helidon.webserver.SocketConfiguration.SocketConfigurationBuilder
bindAddress, host, tls
-
-
-
-
Method Detail
-
build
public WebServer build()
Builds theWebServer
instance as configured by this builder and its parameters.- Specified by:
build
in interfaceBuilder<WebServer>
- Returns:
- a ready to use
WebServer
- Throws:
IllegalStateException
- if there are unpaired named routings (as described ataddNamedRouting(String, Routing)
)
-
defaultSocket
public WebServer.Builder defaultSocket(Consumer<SocketConfiguration.Builder> socket)
Configure listener for the default socket.- Parameters:
socket
- socket configuration builder consumer- Returns:
- updated builder
-
transport
public WebServer.Builder transport(Transport transport)
Configure the transport to be used by this server.- Parameters:
transport
- transport to use- Returns:
- updated builder instance
-
routing
public WebServer.Builder routing(Routing defaultRouting)
Configure the default routing of this WebServer. Default routing is the one available on the default listenhost
andport
of the WebServer- Parameters:
defaultRouting
- new default routing; if already configured, this instance would replace the existing instance- Returns:
- updated builder instance
-
routing
public WebServer.Builder routing(Supplier<Routing> defaultRouting)
Configure the default routing of this WebServer. Default routing is the one available on the default listenhost
andport
of the WebServer- Parameters:
defaultRouting
- new default routing; if already configured, this instance would replace the existing instance- Returns:
- updated builder instance
-
config
@Deprecated public WebServer.Builder config(ServerConfiguration configuration)
Deprecated.since 2.0.0 - please use methods on this builder, orconfig(io.helidon.config.Config)
insteadSet a configuration of theWebServer
. Once this method is called, all other methods on this interface related to server configuration are ignored.- Parameters:
configuration
- the configuration- Returns:
- an updated builder
-
config
@Deprecated public WebServer.Builder config(Supplier<ServerConfiguration> configurationBuilder)
Deprecated.since 2.0.0 - seeconfig(ServerConfiguration)
Set a configuration of theWebServer
.- Parameters:
configurationBuilder
- the configuration builder- Returns:
- an updated builder
-
config
public WebServer.Builder config(Config config)
Update this server configuration from the config provided.- Specified by:
config
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
config
- config located on server node- Returns:
- an updated builder
- Since:
- 2.0.0
-
addNamedRouting
public WebServer.Builder addNamedRouting(String name, Routing routing)
Associates a dedicated routing with an additional server socket configuration.The additional server socket configuration must be set as per
ServerConfiguration.Builder.addSocket(String, SocketConfiguration)
. If there is no such named server socket configuration, aIllegalStateException
is thrown by thebuild()
method.- Parameters:
name
- the named server socket configuration to associate the provided routing withrouting
- the routing to associate with the provided name of a named server socket configuration- Returns:
- an updated builder
-
addNamedRouting
public WebServer.Builder addNamedRouting(String name, Supplier<Routing> routingBuilder)
Associates a dedicated routing with an additional server socket configuration.The additional server socket configuration must be set as per
ServerConfiguration.Builder.addSocket(String, SocketConfiguration)
. If there is no such named server socket configuration, aIllegalStateException
is thrown by thebuild()
method.- Parameters:
name
- the named server socket configuration to associate the provided routing withroutingBuilder
- the routing builder to associate with the provided name of a named server socket configuration; will be built as a first step of this method execution- Returns:
- an updated builder
-
mediaContext
public WebServer.Builder mediaContext(MediaContext mediaContext)
Description copied from interface:ParentingMediaContextBuilder
Sets theMediaContext
parent and overrides the existing one. This method discards all previously registered readers and writers via builder.- Specified by:
mediaContext
in interfaceParentingMediaContextBuilder<WebServer.Builder>
- Parameters:
mediaContext
- media context- Returns:
- updated instance of the builder
-
addMediaSupport
public WebServer.Builder addMediaSupport(MediaSupport mediaSupport)
Description copied from interface:MediaContextBuilder
Adds new instance ofMediaSupport
.- Specified by:
addMediaSupport
in interfaceMediaContextBuilder<WebServer.Builder>
- Parameters:
mediaSupport
- media support- Returns:
- updated instance of the builder
-
addReader
public WebServer.Builder addReader(MessageBodyReader<?> reader)
Description copied from interface:MediaContextBuilder
Registers new reader.- Specified by:
addReader
in interfaceMediaContextBuilder<WebServer.Builder>
- Parameters:
reader
- reader- Returns:
- updated instance of the builder
-
addStreamReader
public WebServer.Builder addStreamReader(MessageBodyStreamReader<?> streamReader)
Description copied from interface:MediaContextBuilder
Registers new stream reader.- Specified by:
addStreamReader
in interfaceMediaContextBuilder<WebServer.Builder>
- Parameters:
streamReader
- stream reader- Returns:
- updated instance of the builder
-
addWriter
public WebServer.Builder addWriter(MessageBodyWriter<?> writer)
Description copied from interface:MediaContextBuilder
Registers new writer.- Specified by:
addWriter
in interfaceMediaContextBuilder<WebServer.Builder>
- Parameters:
writer
- writer- Returns:
- updated instance of the builder
-
addStreamWriter
public WebServer.Builder addStreamWriter(MessageBodyStreamWriter<?> streamWriter)
Description copied from interface:MediaContextBuilder
Registers new stream writer.- Specified by:
addStreamWriter
in interfaceMediaContextBuilder<WebServer.Builder>
- Parameters:
streamWriter
- stream writer- Returns:
- updated instance of the builder
-
port
public WebServer.Builder port(int port)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Configures a server port to listen on with the server socket. If port is0
then any available ephemeral port will be used.- Specified by:
port
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
port
- the server port of the server socket- Returns:
- this builder
-
bindAddress
public WebServer.Builder bindAddress(InetAddress bindAddress)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Configures local address where the server listens on with the server socket. If not configured, then listens an all local addresses.- Specified by:
bindAddress
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
bindAddress
- an address to bind with the server socket- Returns:
- this builder
-
backlog
public WebServer.Builder backlog(int backlog)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Configures a maximum length of the queue of incoming connections on the server socket.Default value is
SocketConfiguration.DEFAULT_BACKLOG_SIZE
.- Specified by:
backlog
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
backlog
- a maximum length of the queue of incoming connections- Returns:
- this builder
-
timeout
public WebServer.Builder timeout(long amount, TimeUnit unit)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Configures a server socket timeout.- Specified by:
timeout
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
amount
- an amount of time to configure the timeout, use0
for infinite timeoutunit
- time unit to use with the configured amount- Returns:
- this builder
-
receiveBufferSize
public WebServer.Builder receiveBufferSize(int receiveBufferSize)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Configures proposed value of the TCP receive window that is advertised to the remote peer on the server socket.If
0
then use implementation default.- Specified by:
receiveBufferSize
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
receiveBufferSize
- a buffer size in bytes of the server socket or0
- Returns:
- this builder
-
tls
public WebServer.Builder tls(WebServerTls webServerTls)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Configures SSL for this socket. When configured, the server enforces SSL configuration. If this method is called, any other method except forSocketConfiguration.SocketConfigurationBuilder.tls(java.util.function.Supplier)
ยจ and repeated invocation of this method would be ignored.If this method is called again, the previous configuration would be ignored.
- Specified by:
tls
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
webServerTls
- ssl configuration to use with this socket- Returns:
- this builder
-
maxHeaderSize
public WebServer.Builder maxHeaderSize(int size)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Maximal number of bytes of all header values combined. When a bigger value is received, aHttp.Status.BAD_REQUEST_400
is returned.Default is
16384
- Specified by:
maxHeaderSize
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
size
- maximal number of bytes of combined header values- Returns:
- this builder
-
maxInitialLineLength
public WebServer.Builder maxInitialLineLength(int length)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Maximal number of characters in the initial HTTP line.Default is
4096
- Specified by:
maxInitialLineLength
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
length
- maximal number of characters- Returns:
- this builder
-
enableCompression
public WebServer.Builder enableCompression(boolean value)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Enable negotiation for gzip/deflate content encodings. Clients can request compression using the "Accept-Encoding" header.Default is
false
- Specified by:
enableCompression
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
value
- compression flag- Returns:
- this builder
-
maxPayloadSize
public WebServer.Builder maxPayloadSize(long size)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Set a maximum payload size for a client request. Can prevent DoS attacks.- Specified by:
maxPayloadSize
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
size
- maximum payload size- Returns:
- this builder
-
backpressureBufferSize
public WebServer.Builder backpressureBufferSize(long backpressureBufferSize)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Maximum length of the response data sending buffer can keep without flushing. Depends on `backpressure-policy` what happens if max buffer size is reached.- Specified by:
backpressureBufferSize
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
backpressureBufferSize
- maximum non-flushed data Netty can buffer until backpressure is applied- Returns:
- this builder
-
backpressureStrategy
public WebServer.Builder backpressureStrategy(BackpressureStrategy backpressureStrategy)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Sets a backpressure strategy for the server to apply against user provided response upstream.- LINEAR - Data are requested one-by-one, in case buffer reaches watermark, no other data is requested.
- AUTO_FLUSH - Data are requested one-by-one, in case buffer reaches watermark, no other data is requested.
- PREFETCH - After first data chunk arrives, probable number of chunks needed to fill the buffer up to watermark is calculated and requested.
- NONE - No backpressure is applied, Long.MAX_VALUE(unbounded) is requested from upstream.
- Specified by:
backpressureStrategy
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
backpressureStrategy
- One of NONE, PREFETCH, LINEAR or AUTO_FLUSH, default is AUTO_FLUSH- Returns:
- this builder
-
continueImmediately
public WebServer.Builder continueImmediately(boolean continueImmediately)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
When true WebServer answers to expect continue with 100 continue immediately, not waiting for user to actually request the data.Default is
false
- Specified by:
continueImmediately
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
continueImmediately
- , answer with 100 continue immediately after expect continue, default is false- Returns:
- this builder
-
addRequestedUriDiscoveryType
public WebServer.Builder addRequestedUriDiscoveryType(SocketConfiguration.RequestedUriDiscoveryType type)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Adds a type of front-end URI discovery Helidon should use for this socket. Adding a discovery type automatically enables discovery for the socket.- Specified by:
addRequestedUriDiscoveryType
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
type
- type to add- Returns:
- updated builder
-
requestedUriDiscoveryTypes
public WebServer.Builder requestedUriDiscoveryTypes(List<SocketConfiguration.RequestedUriDiscoveryType> types)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Assigns the front-end URI discovery type(s) this socket should use. This setting automatically enables discovery for the socket.- Specified by:
requestedUriDiscoveryTypes
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
types
-SocketConfiguration.RequestedUriDiscoveryType
values to assign- Returns:
- updated builder
- See Also:
SocketConfiguration.SocketConfigurationBuilder.addRequestedUriDiscoveryType(io.helidon.webserver.SocketConfiguration.RequestedUriDiscoveryType)
,SocketConfiguration.SocketConfigurationBuilder.requestedUriDiscoveryEnabled(boolean)
,ServerRequest.requestedUri()
-
requestedUriDiscoveryEnabled
public WebServer.Builder requestedUriDiscoveryEnabled(boolean enabled)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Sets whether requested URI discovery is enabled for the socket.- Specified by:
requestedUriDiscoveryEnabled
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
enabled
- whether to enable discovery- Returns:
- updated builder
- See Also:
ServerRequest.requestedUri()
-
trustedProxies
public WebServer.Builder trustedProxies(AllowList trustedProxies)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Assigns the settings governing the acceptance and rejection of forwarded headers from incoming requests to this socket. This setting automatically enables discovery for the socket.- Specified by:
trustedProxies
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
trustedProxies
- to apply to forwarded headers- Returns:
- updated builder
- See Also:
ServerRequest.requestedUri()
-
experimental
public WebServer.Builder experimental(ExperimentalConfiguration experimental)
Configure experimental features.- Parameters:
experimental
- experimental configuration- Returns:
- an updated builder
-
connectionIdleTimeout
public WebServer.Builder connectionIdleTimeout(int seconds)
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Sets the number of seconds after which an idle connection will be automatically closed by the server.- Specified by:
connectionIdleTimeout
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
seconds
- time in seconds- Returns:
- updated builder
-
update
public WebServer.Builder update(Consumer<WebServer.Builder> updateFunction)
A helper method to support fluentAPI when invoking another method.Example:
WebServer.Builder builder = WebServer.builder(); updateBuilder(builder); return builder.build();
Can be changed to:return WebServer.builder() .update(this::updateBuilder) .build();
- Parameters:
updateFunction
- function to update this builder- Returns:
- an updated builder
-
addSocket
@Deprecated public WebServer.Builder addSocket(String name, SocketConfiguration socketConfiguration)
Deprecated.since 2.0.0, please useaddSocket(SocketConfiguration)
instead, name is now part of socket configurationAdds an additional named server socket configuration. As a result, the server will listen on multiple ports.An additional named server socket may have a dedicated
Routing
configured throughaddNamedRouting(String, Routing)
.- Parameters:
name
- the name of the additional server socket configurationsocketConfiguration
- the additional named server socket configuration, never null- Returns:
- an updated builder
-
addSocket
public WebServer.Builder addSocket(SocketConfiguration config)
Adds an additional named server socket configuration. As a result, the server will listen on multiple ports.An additional named server socket may have a dedicated
Routing
configured throughaddNamedRouting(String, Routing)
.- Parameters:
config
- the additional named server socket configuration, never null- Returns:
- an updated builder
-
addSocket
@Deprecated public WebServer.Builder addSocket(String name, Supplier<SocketConfiguration> socketConfigurationBuilder)
Deprecated.since 2.0.0, please useaddSocket(Supplier)
instead, name is now part of socket configurationAdds an additional named server socket configuration builder. As a result, the server will listen on multiple ports.An additional named server socket may have a dedicated
Routing
configured throughaddNamedRouting(String, Routing)
.- Parameters:
name
- the name of the additional server socket configurationsocketConfigurationBuilder
- the additional named server socket configuration builder; will be built as a first step of this method execution- Returns:
- an updated builder
-
addSocket
public WebServer.Builder addSocket(Supplier<SocketConfiguration> socketConfigurationBuilder)
Adds an additional named server socket configuration builder. As a result, the server will listen on multiple ports.An additional named server socket may have a dedicated
Routing
configured throughaddNamedRouting(String, Routing)
.- Parameters:
socketConfigurationBuilder
- the additional named server socket configuration builder; will be built as a first step of this method execution- Returns:
- an updated builder
-
addSocket
public WebServer.Builder addSocket(SocketConfiguration socketConfiguration, Routing routing)
Add a named socket and routing.- Parameters:
socketConfiguration
- named configuration of the socketrouting
- routing to use for this socket- Returns:
- an updated builder
-
tracer
public WebServer.Builder tracer(Tracer tracer)
Sets an opentracing.io tracer. (Default isGlobalTracer
.)- Parameters:
tracer
- a tracer to set- Returns:
- an updated builder
-
tracer
public WebServer.Builder tracer(Supplier<? extends Tracer> tracerBuilder)
Sets an opentracing.io tracer. (Default isGlobalTracer
.)- Parameters:
tracerBuilder
- a tracer builder to set; will be built as a first step of this method execution- Returns:
- updated builder
-
hasSocket
public boolean hasSocket(String socketName)
A method to validate a named socket configuration exists in this builder.- Parameters:
socketName
- name of the socket, usingWebServer.DEFAULT_SOCKET_NAME
will always returntrue
- Returns:
true
in case the named socket is configured in this builder
-
context
public WebServer.Builder context(Context context)
Configure the application scoped context to be used as a parent for webserver request contexts.- Parameters:
context
- top level context- Returns:
- an updated builder
-
workersCount
public WebServer.Builder workersCount(int workers)
Sets a count of threads in pool used to process HTTP requests. Default value isCPU_COUNT * 2
.Configuration key:
workers
- Parameters:
workers
- a workers count- Returns:
- an updated builder
-
printFeatureDetails
public WebServer.Builder printFeatureDetails(boolean shouldPrint)
Set totrue
to print detailed feature information on startup.- Parameters:
shouldPrint
- whether to print details or not- Returns:
- updated builder instance
- See Also:
HelidonFeatures
-
directHandler
public WebServer.Builder directHandler(DirectHandler handler, DirectHandler.EventType... types)
Provide a custom handler for events that bypass routing. The handler can customize status, headers and message.Examples of bad request (
DirectHandler.EventType.BAD_REQUEST
:- Invalid character in path
- Content-Length header set to a non-integer value
- Invalid first line of the HTTP request
- Parameters:
handler
- direct handler to usetypes
- event types to handle with the provided handler- Returns:
- updated builder
-
-