- All Implemented Interfaces:
Builder<WebServer.Builder,,WebServer> MediaContextBuilder<WebServer.Builder>,ParentingMediaContextBuilder<WebServer.Builder>,SocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>,Supplier<WebServer>
- Enclosing interface:
- WebServer
-
Method Summary
Modifier and TypeMethodDescriptionaddMediaSupport(MediaSupport mediaSupport) 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) 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) addStreamWriter(MessageBodyStreamWriter<?> streamWriter) addWriter(MessageBodyWriter<?> writer) backlog(int backlog) Configures a maximum length of the queue of incoming connections on the server socket.bindAddress(InetAddress bindAddress) Configures local address where the server listens on with the server socket.build()Builds theWebServerinstance as configured by this builder and its parameters.Update this server configuration from the config provided.context(io.helidon.common.context.Context context) Configure the application scoped context to be used as a parent for webserver request contexts.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.booleanA 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) port(int port) Configures a server port to listen on with the server socket.printFeatureDetails(boolean shouldPrint) Set totrueto 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.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.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, waitMethods inherited from interface io.helidon.webserver.SocketConfiguration.SocketConfigurationBuilder
bindAddress, host, tls
-
Method Details
-
build
Builds theWebServerinstance as configured by this builder and its parameters.- Specified by:
buildin 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 listenhostandportof 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 listenhostandportof 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 listenhostandportof 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 listenhostandportof 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 listenhostandportof 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:
configin 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, aIllegalStateExceptionis 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, aIllegalStateExceptionis 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
- Specified by:
mediaContextin interfaceParentingMediaContextBuilder<WebServer.Builder>
-
addMediaSupport
- Specified by:
addMediaSupportin interfaceMediaContextBuilder<WebServer.Builder>
-
addReader
- Specified by:
addReaderin interfaceMediaContextBuilder<WebServer.Builder>
-
addStreamReader
- Specified by:
addStreamReaderin interfaceMediaContextBuilder<WebServer.Builder>
-
addWriter
- Specified by:
addWriterin interfaceMediaContextBuilder<WebServer.Builder>
-
addStreamWriter
- Specified by:
addStreamWriterin interfaceMediaContextBuilder<WebServer.Builder>
-
port
Description copied from interface:SocketConfiguration.SocketConfigurationBuilderConfigures a server port to listen on with the server socket. If port is0then any available ephemeral port will be used.- Specified by:
portin interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>- Parameters:
port- the server port of the server socket- Returns:
- this builder
-
bindAddress
Description copied from interface:SocketConfiguration.SocketConfigurationBuilderConfigures local address where the server listens on with the server socket. If not configured, then listens an all local addresses.- Specified by:
bindAddressin interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>- Parameters:
bindAddress- an address to bind with the server socket- Returns:
- this builder
-
backlog
Description copied from interface:SocketConfiguration.SocketConfigurationBuilderConfigures a maximum length of the queue of incoming connections on the server socket.Default value is
SocketConfiguration.DEFAULT_BACKLOG_SIZE.- Specified by:
backlogin interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>- Parameters:
backlog- a maximum length of the queue of incoming connections- Returns:
- this builder
-
timeout
Description copied from interface:SocketConfiguration.SocketConfigurationBuilderConfigures a server socket timeout.- Specified by:
timeoutin interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>- Parameters:
amount- an amount of time to configure the timeout, use0for infinite timeoutunit- time unit to use with the configured amount- Returns:
- this builder
-
receiveBufferSize
Description copied from interface:SocketConfiguration.SocketConfigurationBuilderConfigures proposed value of the TCP receive window that is advertised to the remote peer on the server socket.If
0then use implementation default.- Specified by:
receiveBufferSizein 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.SocketConfigurationBuilderConfigures 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:
tlsin interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>- Parameters:
webServerTls- ssl configuration to use with this socket- Returns:
- this builder
-
maxHeaderSize
Description copied from interface:SocketConfiguration.SocketConfigurationBuilderMaximal number of bytes of all header values combined. When a bigger value is received, aHttp.Status.BAD_REQUEST_400is returned.Default is
8192- Specified by:
maxHeaderSizein interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>- Parameters:
size- maximal number of bytes of combined header values- Returns:
- this builder
-
maxInitialLineLength
Description copied from interface:SocketConfiguration.SocketConfigurationBuilderMaximal number of characters in the initial HTTP line.Default is
4096- Specified by:
maxInitialLineLengthin interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>- Parameters:
length- maximal number of characters- Returns:
- this builder
-
enableCompression
Description copied from interface:SocketConfiguration.SocketConfigurationBuilderEnable negotiation for gzip/deflate content encodings. Clients can request compression using the "Accept-Encoding" header.Default is
false- Specified by:
enableCompressionin interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>- Parameters:
value- compression flag- Returns:
- this builder
-
maxPayloadSize
Description copied from interface:SocketConfiguration.SocketConfigurationBuilderSet a maximum payload size for a client request. Can prevent DoS attacks.- Specified by:
maxPayloadSizein interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>- Parameters:
size- maximum payload size- Returns:
- this builder
-
maxUpgradeContentLength
Description copied from interface:SocketConfiguration.SocketConfigurationBuilderSet a maximum length of the content of an upgrade request.Default is
64*1024- Specified by:
maxUpgradeContentLengthin interfaceSocketConfiguration.SocketConfigurationBuilder<WebServer.Builder>- Parameters:
size- Maximum length of the content of an upgrade request- Returns:
- this 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:
updatein 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
Routingconfigured 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
Routingconfigured 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
Routingconfigured 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
Routingconfigured 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_NAMEwill always returntrue- Returns:
truein 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 totrueto 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.