Class HttpServer
- All Implemented Interfaces:
MutinyDelegate,Measured
You receive HTTP requests by providing a requestHandler(java.util.function.Consumer<io.vertx.mutiny.core.http.HttpServerRequest>). As requests arrive on the server the handler
will be called with the requests.
You receive WebSockets by providing a webSocketHandler(java.util.function.Consumer<io.vertx.mutiny.core.http.ServerWebSocket>). As WebSocket connections arrive on the server, the
WebSocket is passed to the handler.
NOTE: This class has been automatically generated from the original non Mutiny-ified interface.
- Author:
- Tim Fox
- See Also:
-
HttpServer
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.vertx.mutiny.core.metrics.Measured
Measured.MeasuredImpl -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHttpServer(io.vertx.core.http.HttpServer delegate) Create a new instance ofHttpServerdelegating to the given (non-null) instance ofHttpServer.HttpServer(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionintThe actual port the server is listening on.io.smallrye.mutiny.Uni<Void>close()Close the server.voidClose the server.Close the server.connectionHandler(Consumer<HttpConnection> handler) Set a connection handler for the server.booleanexceptionHandler(Consumer<Throwable> handler) Set an exception handler called for socket errors happening before the HTTP connection is established, e.g. during the TLS handshake.io.vertx.core.http.HttpServerGet the delegate instance.inthashCode()invalidRequestHandler(Consumer<HttpServerRequest> handler) Set ahandlerfor handling invalid requests.booleanWhether the metrics are enabled for this measured objectio.smallrye.mutiny.Uni<HttpServer>listen()Tell the server to start listening.io.smallrye.mutiny.Uni<HttpServer>listen(int port) Likelisten(int, String)but the server will listen on host "0.0.0.0" and port specified here ignoring any value in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.io.smallrye.mutiny.Uni<HttpServer>Tell the server to start listening.io.smallrye.mutiny.Uni<HttpServer>listen(io.vertx.core.net.SocketAddress address) Tell the server to start listening on the given address supplying a handler that will be called when the server is actually listening (or has failed).Tell the server to start listening.listenAndAwait(int port) Likelisten(int, String)but the server will listen on host "0.0.0.0" and port specified here ignoring any value in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.listenAndAwait(int port, String host) Tell the server to start listening.listenAndAwait(io.vertx.core.net.SocketAddress address) Tell the server to start listening on the given address supplying a handler that will be called when the server is actually listening (or has failed).Tell the server to start listening.listenAndForget(int port) Likelisten(int, String)but the server will listen on host "0.0.0.0" and port specified here ignoring any value in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.listenAndForget(int port, String host) Tell the server to start listening.listenAndForget(io.vertx.core.net.SocketAddress address) Tell the server to start listening on the given address supplying a handler that will be called when the server is actually listening (or has failed).static HttpServernewInstance(io.vertx.core.http.HttpServer delegate) Creates a new instance of theHttpServer.requestHandler(Consumer<HttpServerRequest> handler) Set the request handler for the server torequestHandler.io.smallrye.mutiny.Uni<Void>shutdown()Shutdown with a 30 seconds timeout (shutdown(Duration.ofSeconds(30))).io.smallrye.mutiny.Uni<Void>Callsshutdown(Duration).io.smallrye.mutiny.Uni<Void>Initiate the server shutdown sequence.voidShutdown with a 30 seconds timeout (shutdown(Duration.ofSeconds(30))).voidshutdownAndAwait(long timeout, TimeUnit unit) Callsshutdown(Duration).voidshutdownAndAwait(Duration timeout) Initiate the server shutdown sequence.Shutdown with a 30 seconds timeout (shutdown(Duration.ofSeconds(30))).shutdownAndForget(long timeout, TimeUnit unit) Callsshutdown(Duration).shutdownAndForget(Duration timeout) Initiate the server shutdown sequence.toString()io.smallrye.mutiny.Uni<Boolean>updateSSLOptions(io.vertx.core.net.ServerSSLOptions options) Update the server with new SSLoptions, the update happens if the options object is valid and different from the existing options object.io.smallrye.mutiny.Uni<Boolean>updateSSLOptions(io.vertx.core.net.ServerSSLOptions options, boolean force) Update the server with new SSLoptions, the update happens if the options object is valid and different from the existing options object.updateSSLOptionsAndAwait(io.vertx.core.net.ServerSSLOptions options) Update the server with new SSLoptions, the update happens if the options object is valid and different from the existing options object.updateSSLOptionsAndAwait(io.vertx.core.net.ServerSSLOptions options, boolean force) Update the server with new SSLoptions, the update happens if the options object is valid and different from the existing options object.updateSSLOptionsAndForget(io.vertx.core.net.ServerSSLOptions options) Update the server with new SSLoptions, the update happens if the options object is valid and different from the existing options object.updateSSLOptionsAndForget(io.vertx.core.net.ServerSSLOptions options, boolean force) Update the server with new SSLoptions, the update happens if the options object is valid and different from the existing options object.io.smallrye.mutiny.Uni<Boolean>updateTrafficShapingOptions(io.vertx.core.net.TrafficShapingOptions options) Update the server with new trafficoptions, the update happens if the options object is valid and different from the existing options object.updateTrafficShapingOptionsAndAwait(io.vertx.core.net.TrafficShapingOptions options) Update the server with new trafficoptions, the update happens if the options object is valid and different from the existing options object.updateTrafficShapingOptionsAndForget(io.vertx.core.net.TrafficShapingOptions options) Update the server with new trafficoptions, the update happens if the options object is valid and different from the existing options object.webSocketHandler(Consumer<ServerWebSocket> handler) Set the WebSocket handler for the server towsHandler.Set a handler for WebSocket handshake.
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
HttpServer
public HttpServer(io.vertx.core.http.HttpServer delegate) Create a new instance ofHttpServerdelegating to the given (non-null) instance ofHttpServer. -
HttpServer
-
-
Method Details
-
getDelegate
public io.vertx.core.http.HttpServer getDelegate()Get the delegate instance.This method returns the instance on which this shim is delegating the calls. And so, give you access to the bare API.
- Specified by:
getDelegatein interfaceMeasured- Specified by:
getDelegatein interfaceMutinyDelegate- Returns:
- the delegate instance
-
updateSSLOptions
@CheckReturnValue public io.smallrye.mutiny.Uni<Boolean> updateSSLOptions(io.vertx.core.net.ServerSSLOptions options) Update the server with new SSLoptions, the update happens if the options object is valid and different from the existing options object.The boolean succeeded uni result indicates whether the update occurred.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
options- the new SSL options- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServer.updateSSLOptions(ServerSSLOptions)
-
updateSSLOptionsAndAwait
Update the server with new SSLoptions, the update happens if the options object is valid and different from the existing options object.The boolean succeeded underlying uni result indicates whether the update occurred.
Unlike the bare Vert.x variant, this method returns a
Boolean. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
options- the new SSL options- Returns:
- The operation result
- See Also:
-
HttpServer.updateSSLOptions(ServerSSLOptions)
-
updateSSLOptionsAndForget
Update the server with new SSLoptions, the update happens if the options object is valid and different from the existing options object.The boolean succeeded underlying uni result indicates whether the update occurred.
Unlike the bare Vert.x variant, this method ignores the
Booleanresult or any failure.- Parameters:
options- the new SSL options- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServer.updateSSLOptions(ServerSSLOptions)
-
updateSSLOptions
@CheckReturnValue public io.smallrye.mutiny.Uni<Boolean> updateSSLOptions(io.vertx.core.net.ServerSSLOptions options, boolean force) Update the server with new SSL
options, the update happens if the options object is valid and different from the existing options object.The
optionsobject is compared using itsequalsmethod against the existing options to prevent an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. When object are equals, settingforcetotrueforces the update.The boolean succeeded uni result indicates whether the update occurred.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
options- the new SSL optionsforce- force the update when options are equals- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServer.updateSSLOptions(ServerSSLOptions, boolean)
-
updateSSLOptionsAndAwait
Update the server with new SSL
options, the update happens if the options object is valid and different from the existing options object.The
optionsobject is compared using itsequalsmethod against the existing options to prevent an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. When object are equals, settingforcetotrueforces the update.The boolean succeeded underlying uni result indicates whether the update occurred.
Unlike the bare Vert.x variant, this method returns a
Boolean. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
options- the new SSL optionsforce- force the update when options are equals- Returns:
- The operation result
- See Also:
-
HttpServer.updateSSLOptions(ServerSSLOptions, boolean)
-
updateSSLOptionsAndForget
public HttpServer updateSSLOptionsAndForget(io.vertx.core.net.ServerSSLOptions options, boolean force) Update the server with new SSL
options, the update happens if the options object is valid and different from the existing options object.The
optionsobject is compared using itsequalsmethod against the existing options to prevent an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. When object are equals, settingforcetotrueforces the update.The boolean succeeded underlying uni result indicates whether the update occurred.
Unlike the bare Vert.x variant, this method ignores the
Booleanresult or any failure.- Parameters:
options- the new SSL optionsforce- force the update when options are equals- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServer.updateSSLOptions(ServerSSLOptions, boolean)
-
updateTrafficShapingOptions
@CheckReturnValue public io.smallrye.mutiny.Uni<Boolean> updateTrafficShapingOptions(io.vertx.core.net.TrafficShapingOptions options) Update the server with new traffic
options, the update happens if the options object is valid and different from the existing options object.The
optionsobject is compared using itsequalsmethod against the existing options to prevent an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. When object are equals, settingforcetotrueforces the update.The boolean succeeded uni result indicates whether the update occurred.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
options- the new traffic shaping options- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServer.updateTrafficShapingOptions(TrafficShapingOptions)
-
updateTrafficShapingOptionsAndAwait
Update the server with new traffic
options, the update happens if the options object is valid and different from the existing options object.The
optionsobject is compared using itsequalsmethod against the existing options to prevent an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. When object are equals, settingforcetotrueforces the update.The boolean succeeded underlying uni result indicates whether the update occurred.
Unlike the bare Vert.x variant, this method returns a
Boolean. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
options- the new traffic shaping options- Returns:
- The operation result
- See Also:
-
HttpServer.updateTrafficShapingOptions(TrafficShapingOptions)
-
updateTrafficShapingOptionsAndForget
public HttpServer updateTrafficShapingOptionsAndForget(io.vertx.core.net.TrafficShapingOptions options) Update the server with new traffic
options, the update happens if the options object is valid and different from the existing options object.The
optionsobject is compared using itsequalsmethod against the existing options to prevent an update when the objects are equals since loading options can be costly, this can happen for share TCP servers. When object are equals, settingforcetotrueforces the update.The boolean succeeded underlying uni result indicates whether the update occurred.
Unlike the bare Vert.x variant, this method ignores the
Booleanresult or any failure.- Parameters:
options- the new traffic shaping options- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServer.updateTrafficShapingOptions(TrafficShapingOptions)
-
listen
Tell the server to start listening. The server will listen on the port and host specified in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.The listen happens asynchronously and the server may not be listening until some time after the call has returned.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServer.listen()
-
listenAndAwait
Tell the server to start listening. The server will listen on the port and host specified in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.The listen happens asynchronously and the server may not be listening until some time after the call has returned.
Unlike the bare Vert.x variant, this method returns a
HttpServer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Returns:
- The operation result
- See Also:
-
HttpServer.listen()
-
listenAndForget
Tell the server to start listening. The server will listen on the port and host specified in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.The listen happens asynchronously and the server may not be listening until some time after the call has returned.
Unlike the bare Vert.x variant, this method ignores the
HttpServerresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServer.listen()
-
listen
Tell the server to start listening. The server will listen on the port and host specified here, ignoring any value set in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.The listen happens asynchronously and the server may not be listening until some time after the call has returned.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
port- the port to listen onhost- the host to listen on- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServer.listen(int, String)
-
listenAndAwait
Tell the server to start listening. The server will listen on the port and host specified here, ignoring any value set in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.The listen happens asynchronously and the server may not be listening until some time after the call has returned.
Unlike the bare Vert.x variant, this method returns a
HttpServer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
port- the port to listen onhost- the host to listen on- Returns:
- The operation result
- See Also:
-
HttpServer.listen(int, String)
-
listenAndForget
Tell the server to start listening. The server will listen on the port and host specified here, ignoring any value set in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.The listen happens asynchronously and the server may not be listening until some time after the call has returned.
Unlike the bare Vert.x variant, this method ignores the
HttpServerresult or any failure.- Parameters:
port- the port to listen onhost- the host to listen on- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServer.listen(int, String)
-
listen
@CheckReturnValue public io.smallrye.mutiny.Uni<HttpServer> listen(io.vertx.core.net.SocketAddress address) Tell the server to start listening on the given address supplying a handler that will be called when the server is actually listening (or has failed).Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
address- the address to listen on- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServer.listen(SocketAddress)
-
listenAndAwait
Tell the server to start listening on the given address supplying a handler that will be called when the server is actually listening (or has failed).Unlike the bare Vert.x variant, this method returns a
HttpServer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
address- the address to listen on- Returns:
- The operation result
- See Also:
-
HttpServer.listen(SocketAddress)
-
listenAndForget
Tell the server to start listening on the given address supplying a handler that will be called when the server is actually listening (or has failed).Unlike the bare Vert.x variant, this method ignores the
HttpServerresult or any failure.- Parameters:
address- the address to listen on- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServer.listen(SocketAddress)
-
listen
Likelisten(int, String)but the server will listen on host "0.0.0.0" and port specified here ignoring any value in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
port- the port to listen on- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServer.listen(int)
-
listenAndAwait
Likelisten(int, String)but the server will listen on host "0.0.0.0" and port specified here ignoring any value in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.Unlike the bare Vert.x variant, this method returns a
HttpServer. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
port- the port to listen on- Returns:
- The operation result
- See Also:
-
HttpServer.listen(int)
-
listenAndForget
Likelisten(int, String)but the server will listen on host "0.0.0.0" and port specified here ignoring any value in theio.vertx.mutiny.core.http.HttpServerOptionsthat was used when creating the server.Unlike the bare Vert.x variant, this method ignores the
HttpServerresult or any failure.- Parameters:
port- the port to listen on- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServer.listen(int)
-
close
Close the server. Any open HTTP connections will be closed.The close happens asynchronously and the server may not be closed until some time after the call has returned.
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServer.close()
-
closeAndAwait
public void closeAndAwait()Close the server. Any open HTTP connections will be closed.The close happens asynchronously and the server may not be closed until some time after the call has returned.
Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
HttpServer.close()
-
closeAndForget
Close the server. Any open HTTP connections will be closed.The close happens asynchronously and the server may not be closed until some time after the call has returned.
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServer.close()
-
shutdown
Shutdown with a 30 seconds timeout (shutdown(Duration.ofSeconds(30))).Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServer.shutdown()
-
shutdownAndAwait
public void shutdownAndAwait()Shutdown with a 30 seconds timeout (shutdown(Duration.ofSeconds(30))).Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
HttpServer.shutdown()
-
shutdownAndForget
Shutdown with a 30 seconds timeout (shutdown(Duration.ofSeconds(30))).Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServer.shutdown()
-
shutdown
Callsshutdown(Duration).Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServer.shutdown(long, TimeUnit)
-
shutdownAndAwait
Callsshutdown(Duration).Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- See Also:
-
HttpServer.shutdown(long, TimeUnit)
-
shutdownAndForget
Callsshutdown(Duration).Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServer.shutdown(long, TimeUnit)
-
shutdown
Initiate the server shutdown sequence.Connections are taken out of service and closed when all inflight requests are processed. When all connections are closed the server is closed. When the
timeoutexpires, all unclosed connections are immediately closed.- HTTP/2 connections will send a go away frame immediately to signal the other side the connection will close
- HTTP/1.x server connection will be closed after the current response is sent
Unlike the bare Vert.x variant, this method returns a
Uni. The uni emits the result of the operation as item. If the operation fails, the uni emits the failure.Don't forget to subscribe on it to trigger the operation.
- Parameters:
timeout- the amount of time after which all resources are forcibly closed- Returns:
- A
Unirepresenting the asynchronous result of this operation. - See Also:
-
HttpServer.shutdown(Duration)
-
shutdownAndAwait
Initiate the server shutdown sequence.Connections are taken out of service and closed when all inflight requests are processed. When all connections are closed the server is closed. When the
timeoutexpires, all unclosed connections are immediately closed.- HTTP/2 connections will send a go away frame immediately to signal the other side the connection will close
- HTTP/1.x server connection will be closed after the current response is sent
Unlike the bare Vert.x variant, this method returns a
Void. This method awaits indefinitely for the completion of the underlying asynchronous operation. If the operation completes successfully, the result is returned, otherwise the failure is thrown (potentially wrapped in aRuntimeException).- Parameters:
timeout- the amount of time after which all resources are forcibly closed- See Also:
-
HttpServer.shutdown(Duration)
-
shutdownAndForget
Initiate the server shutdown sequence.Connections are taken out of service and closed when all inflight requests are processed. When all connections are closed the server is closed. When the
timeoutexpires, all unclosed connections are immediately closed.- HTTP/2 connections will send a go away frame immediately to signal the other side the connection will close
- HTTP/1.x server connection will be closed after the current response is sent
Unlike the bare Vert.x variant, this method ignores the
Voidresult or any failure.- Parameters:
timeout- the amount of time after which all resources are forcibly closed- Returns:
- The current instance to chain operations if needed.
- See Also:
-
HttpServer.shutdown(Duration)
-
requestHandler
Set the request handler for the server torequestHandler. As HTTP requests are received by the server, instances ofHttpServerRequestwill be created and passed to this handler.- Returns:
- a reference to this, so the API can be used fluently
-
invalidRequestHandler
Set ahandlerfor handling invalid requests. When an invalid request is received by the server this handler will be called with the request. The handler can send any HTTP response, when the response ends, the server shall close the connection.HttpServerRequest#decoderResult()can be used to obtain the Netty decoder result and the failure cause reported by the decoder.Currently this handler is only used for HTTP/1.x requests.
When no specific handler is set, the
HttpServerRequest#DEFAULT_INVALID_REQUEST_HANDLERis used.- Returns:
- a reference to this, so the API can be used fluently
-
connectionHandler
Set a connection handler for the server.
The handler will always be called on the event-loop thread.- Returns:
- a reference to this, so the API can be used fluently
-
webSocketHandshakeHandler
Set a handler for WebSocket handshake.When an inbound HTTP request presents a WebSocket upgrade, this handler is called first. The handler can chose to
ServerWebSocketHandshake.accept()orServerWebSocketHandshake.reject()the request.Setting no handler, implicitly accepts any HTTP request connection presenting an upgrade header and upgrades it to a WebSocket.
-
exceptionHandler
Set an exception handler called for socket errors happening before the HTTP connection is established, e.g. during the TLS handshake.- Parameters:
handler- the handler to set- Returns:
- a reference to this, so the API can be used fluently
-
webSocketHandler
Set the WebSocket handler for the server towsHandler. If a WebSocket connect handshake is successful a newServerWebSocketinstance will be created and passed to the handler.- Returns:
- a reference to this, so the API can be used fluently
-
actualPort
public int actualPort()The actual port the server is listening on. This is useful if you bound the server specifying 0 as port number signifying an ephemeral port- Returns:
- the actual port the server is listening on.
-
isMetricsEnabled
public boolean isMetricsEnabled()Whether the metrics are enabled for this measured object- Specified by:
isMetricsEnabledin interfaceMeasured- Returns:
trueif metrics are enabled
-
newInstance
Creates a new instance of theHttpServer. -
hashCode
public int hashCode() -
equals
-
toString
-