- All Implemented Interfaces:
Builder<WebServer.Builder,
,WebServer> MediaContextBuilder<WebServer.Builder>
,ParentingMediaContextBuilder<WebServer.Builder>
,SocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
,Supplier<WebServer>
- Enclosing interface:
- WebServer
-
Field Summary
Fields inherited from interface io.helidon.webserver.SocketConfiguration.SocketConfigurationBuilder
REQUESTED_URI_DISCOVERY_CONFIG_KEY_PREFIX
-
Method Summary
Modifier and TypeMethodDescriptionaddMediaSupport
(MediaSupport mediaSupport) Adds new instance ofMediaSupport
.addNamedRouting
(String name, Routing routing) Associates a dedicated routing with an additional server socket configuration.addNamedRouting
(String name, Supplier<Routing> routingBuilder) Associates a dedicated routing with an additional server socket configuration.addReader
(MessageBodyReader<?> reader) Registers new reader.Adds a type of front-end URI discovery Helidon should use for this socket.addRouting
(Routing routing) Configure the default routing of this WebServer.addRouting
(Supplier<Routing> routingSupplier) Configure the default routing of this WebServer.addSocket
(SocketConfiguration config) Adds an additional named server socket configuration.addSocket
(SocketConfiguration socketConfiguration, Routing routing) Add a named socket and routing.addSocket
(Supplier<SocketConfiguration> socketConfigurationBuilder) Adds an additional named server socket configuration builder.addStreamReader
(MessageBodyStreamReader<?> streamReader) Registers new stream reader.addStreamWriter
(MessageBodyStreamWriter<?> streamWriter) Registers new stream writer.addWriter
(MessageBodyWriter<?> writer) Registers new writer.backlog
(int backlog) Configures a maximum length of the queue of incoming connections on the server socket.backpressureBufferSize
(long backpressureBufferSize) Maximum length of the response data sending buffer can keep without flushing.backpressureStrategy
(BackpressureStrategy backpressureStrategy) Sets a backpressure strategy for the server to apply against user provided response upstream.bindAddress
(InetAddress bindAddress) Configures local address where the server listens on with the server socket.build()
Builds theWebServer
instance as configured by this builder and its parameters.Update this server configuration from the config provided.connectionIdleTimeout
(int seconds) Sets the number of seconds after which an idle connection will be automatically closed by the server.Configure the application scoped context to be used as a parent for webserver request contexts.continueImmediately
(boolean continueImmediately) When true WebServer answers to expect continue with 100 continue immediately, not waiting for user to actually request the data.Configure listener for the default socket.directHandler
(DirectHandler handler, DirectHandler.EventType... types) Provide a custom handler for events that bypass routing.enableCompression
(boolean value) Enable negotiation for gzip/deflate content encodings.boolean
A method to validate a named socket configuration exists in this builder.maxHeaderSize
(int size) Maximal number of bytes of all header values combined.maxInitialLineLength
(int length) Maximal number of characters in the initial HTTP line.maxPayloadSize
(long size) Set a maximum payload size for a client request.maxUpgradeContentLength
(int size) Set a maximum length of the content of an upgrade request.mediaContext
(MediaContext mediaContext) Sets theMediaContext
parent and overrides the existing one.port
(int port) Configures a server port to listen on with the server socket.printFeatureDetails
(boolean shouldPrint) Set totrue
to print detailed feature information on startup.receiveBufferSize
(int receiveBufferSize) Configures proposed value of the TCP receive window that is advertised to the remote peer on the server socket.requestedUriDiscoveryEnabled
(boolean enabled) Sets whether requested URI discovery is enabled for the socket.Assigns the front-end URI discovery type(s) this socket should use.Deprecated, for removal: This API element is subject to removal in a future version.routing
(Consumer<Routing.Builder> routing) Configure the default routing of this WebServer.Configure the default routing of this WebServer.socket
(String socketName, BiConsumer<SocketConfiguration.Builder, Router.Builder> builders) Adds or augment existing named server socket configuration.socket
(String name, Consumer<SocketConfiguration.Builder> socket) Adds or augment existing named server socket configuration.Configures a server socket timeout.tls
(WebServerTls webServerTls) Configures SSL for this socket.Sets a tracer.Sets a tracer.Configure the transport to be used by this server.trustedProxies
(AllowList trustedProxies) Assigns the settings governing the acceptance and rejection of forwarded headers from incoming requests to this socket.update
(Consumer<WebServer.Builder> updateFunction) A helper method to support fluentAPI when invoking another method.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 Details
-
build
Builds theWebServer
instance as configured by this builder and its parameters.- Specified by:
build
in interfaceBuilder<WebServer.Builder,
WebServer> - Returns:
- a ready to use
WebServer
- Throws:
IllegalStateException
- if there are unpaired named routings (as described ataddNamedRouting(String, Routing)
)
-
defaultSocket
Configure listener for the default socket.- Parameters:
socket
- socket configuration builder consumer- Returns:
- updated builder
-
transport
Configure the transport to be used by this server.- Parameters:
transport
- transport to use- Returns:
- updated builder instance
-
routing
@Deprecated(since="3.0.0", forRemoval=true) public WebServer.Builder routing(Routing defaultRouting) Deprecated, for removal: This API element is subject to removal in a future version.UseaddRouting(Routing)
oraddRouting(Routing)
instead.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
-
addRouting
Configure the default routing of this WebServer. Default routing is the one available on the default listenhost
andport
of the WebServer- Parameters:
routing
- new default routing; if already configured, this instance would replace the existing instance- Returns:
- updated builder instance
-
addRouting
Configure the default routing of this WebServer. Default routing is the one available on the default listenhost
andport
of the WebServer- Parameters:
routingSupplier
- new default routing; if already configured, this instance would replace the existing instance- Returns:
- updated builder instance
-
routing
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
Configure the default routing of this WebServer. Default routing is the one available on the default listenhost
andport
of the WebServer- Parameters:
routing
- new default routing; if already configured, this instance would replace the existing instance- Returns:
- updated builder instance
-
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
-
maxUpgradeContentLength
Description copied from interface:SocketConfiguration.SocketConfigurationBuilder
Set a maximum length of the content of an upgrade request.Default is
64*1024
- Specified by:
maxUpgradeContentLength
in interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>
- Parameters:
size
- Maximum length of the content of an upgrade request- 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:
-
requestedUriDiscoveryEnabled
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:
-
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:
-
connectionIdleTimeout
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
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();
- Specified by:
update
in interfaceBuilder<WebServer.Builder,
WebServer> - Parameters:
updateFunction
- function to update this builder- Returns:
- an updated builder
-
addSocket
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
-
socket
Adds or augment existing named server socket configuration.An additional named server socket may have a dedicated
Routing
configured throughaddNamedRouting(String, Routing)
.- Parameters:
name
- socket namesocket
- new or existing configuration builder- Returns:
- an updated builder
-
socket
public WebServer.Builder socket(String socketName, BiConsumer<SocketConfiguration.Builder, Router.Builder> builders) Adds or augment existing named server socket configuration.An additional named server socket have a dedicated
Routing
configured through supplied routing builder.- Parameters:
socketName
- socket namebuilders
- consumer with socket configuration and dedicated routing builders- Returns:
- an updated builder
-
addSocket
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
Add a named socket and routing.- Parameters:
socketConfiguration
- named configuration of the socketrouting
- routing to use for this socket- Returns:
- an updated builder
-
tracer
Sets a tracer.- Parameters:
tracer
- a tracer to set- Returns:
- an updated builder
-
tracer
Sets a tracer.- Parameters:
tracerBuilder
- a tracer builder to set; will be built as a first step of this method execution- Returns:
- updated builder
-
hasSocket
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
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
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
Set totrue
to print detailed feature information on startup.- Parameters:
shouldPrint
- whether to print details or not- Returns:
- updated builder instance
- See Also:
-
directHandler
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
-
addRouting(Routing)
oraddRouting(Routing)
instead.