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.
original
non Mutiny-ified interface using Vert.x codegen.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHttpServer
(io.vertx.core.http.HttpServer delegate) HttpServer
(Object delegate) -
Method Summary
Modifier and TypeMethodDescriptionint
io.smallrye.mutiny.Uni<Void>
close()
Likeclose()
but supplying a handler that will be called when the server is actually closed (or has failed).Blocking variant ofclose()
.void
Variant ofclose()
that ignores the result of the operation.connectionHandler
(Consumer<HttpConnection> handler) boolean
exceptionHandler
(Consumer<Throwable> handler) io.vertx.core.http.HttpServer
int
hashCode()
invalidRequestHandler
(Consumer<HttpServerRequest> handler) boolean
io.smallrye.mutiny.Uni<HttpServer>
listen()
Likelisten(int, java.lang.String)
but supplying a handler that will be called when the server is actually listening (or has failed).io.smallrye.mutiny.Uni<HttpServer>
listen
(int port) Likelisten(int, java.lang.String)
but supplying a handler that will be called when the server is actually listening (or has failed).io.smallrye.mutiny.Uni<HttpServer>
Likelisten(int, java.lang.String)
but supplying a handler that will be called when the server is actually listening (or has failed).io.smallrye.mutiny.Uni<HttpServer>
listen
(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).Blocking variant oflisten(int, java.lang.String)
.listenAndAwait
(int port) Blocking variant oflisten(int)
.listenAndAwait
(int port, String host) Blocking variant oflisten(int,String)
.listenAndAwait
(SocketAddress address) Blocking variant oflisten(io.vertx.mutiny.core.net.SocketAddress)
.Variant oflisten(int, java.lang.String)
that ignores the result of the operation.listenAndForget
(int port) Variant oflisten(int)
that ignores the result of the operation.listenAndForget
(int port, String host) Variant oflisten(int,String)
that ignores the result of the operation.listenAndForget
(SocketAddress address) Variant oflisten(io.vertx.mutiny.core.net.SocketAddress)
that ignores the result of the operation.static HttpServer
newInstance
(io.vertx.core.http.HttpServer arg) requestHandler
(Consumer<HttpServerRequest> handler) Deprecated.toString()
io.smallrye.mutiny.Uni<Boolean>
updateSSLOptions
(io.vertx.core.net.SSLOptions options) LikeupdateSSLOptions(io.vertx.core.net.SSLOptions)
but supplying a handler that will be called when the update happened (or has failed).io.smallrye.mutiny.Uni<Boolean>
updateSSLOptions
(io.vertx.core.net.SSLOptions options, boolean force) LikeupdateSSLOptions(io.vertx.core.net.SSLOptions)
but supplying a handler that will be called when the update happened (or has failed).updateSSLOptionsAndAwait
(io.vertx.core.net.SSLOptions options) Blocking variant ofupdateSSLOptions(SSLOptions)
.updateSSLOptionsAndAwait
(io.vertx.core.net.SSLOptions options, boolean force) Blocking variant ofupdateSSLOptions(SSLOptions,boolean)
.void
updateSSLOptionsAndForget
(io.vertx.core.net.SSLOptions options) Variant ofupdateSSLOptions(SSLOptions)
that ignores the result of the operation.void
updateSSLOptionsAndForget
(io.vertx.core.net.SSLOptions options, boolean force) Variant ofupdateSSLOptions(SSLOptions,boolean)
that ignores the result of the operation.void
updateTrafficShapingOptions
(io.vertx.core.net.TrafficShapingOptions options) webSocketHandler
(Consumer<ServerWebSocket> handler) Deprecated.instead use#webSocketHandler(Handler)
-
Field Details
-
__TYPE_ARG
-
-
Constructor Details
-
HttpServer
public HttpServer(io.vertx.core.http.HttpServer delegate) -
HttpServer
-
-
Method Details
-
getDelegate
public io.vertx.core.http.HttpServer getDelegate()- Specified by:
getDelegate
in interfaceMeasured
- Specified by:
getDelegate
in interfaceMutinyDelegate
- Returns:
- the delegate used by this Mutiny object of generated type
-
toString
-
equals
-
hashCode
public int hashCode() -
isMetricsEnabled
public boolean isMetricsEnabled()- Specified by:
isMetricsEnabled
in interfaceMeasured
- Returns:
true
if metrics are enabled
-
requestStream
Deprecated.instead use#requestHandler(Handler)
- Returns:
- the request stream
-
requestHandler
- Parameters:
handler
-- Returns:
-
invalidRequestHandler
- Parameters:
handler
-- Returns:
-
connectionHandler
- Parameters:
handler
-- Returns:
-
exceptionHandler
- Parameters:
handler
- the handler to set- Returns:
-
webSocketStream
Deprecated.instead use#webSocketHandler(Handler)
- Returns:
- the WebSocket stream
-
webSocketHandler
- Parameters:
handler
-- Returns:
-
webSocketHandshakeHandler
- Parameters:
handler
-- Returns:
-
updateSSLOptions
@CheckReturnValue public io.smallrye.mutiny.Uni<Boolean> updateSSLOptions(io.vertx.core.net.SSLOptions options) LikeupdateSSLOptions(io.vertx.core.net.SSLOptions)
but supplying a handler that will be called when the update happened (or has failed).Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Parameters:
options
- the new SSL options- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
updateSSLOptionsAndAwait
Blocking variant ofupdateSSLOptions(SSLOptions)
.This method waits 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 a RuntimeException).
- Parameters:
options
- the new SSL options- Returns:
- the Boolean instance produced by the operation.
-
updateSSLOptionsAndForget
public void updateSSLOptionsAndForget(io.vertx.core.net.SSLOptions options) Variant ofupdateSSLOptions(SSLOptions)
that ignores the result of the operation.This method subscribes on the result of
updateSSLOptions(SSLOptions)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromupdateSSLOptions(SSLOptions)
but you don't need to compose it with other operations.- Parameters:
options
- the new SSL options
-
updateSSLOptions
@CheckReturnValue public io.smallrye.mutiny.Uni<Boolean> updateSSLOptions(io.vertx.core.net.SSLOptions options, boolean force) LikeupdateSSLOptions(io.vertx.core.net.SSLOptions)
but supplying a handler that will be called when the update happened (or has failed).Unlike the bare Vert.x variant, this method returns a
Uni
. 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:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
updateSSLOptionsAndAwait
Blocking variant ofupdateSSLOptions(SSLOptions,boolean)
.This method waits 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 a RuntimeException).
- Parameters:
options
- the new SSL optionsforce
- force the update when options are equals- Returns:
- the Boolean instance produced by the operation.
-
updateSSLOptionsAndForget
public void updateSSLOptionsAndForget(io.vertx.core.net.SSLOptions options, boolean force) Variant ofupdateSSLOptions(SSLOptions,boolean)
that ignores the result of the operation.This method subscribes on the result of
updateSSLOptions(SSLOptions,boolean)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromupdateSSLOptions(SSLOptions,boolean)
but you don't need to compose it with other operations.- Parameters:
options
- the new SSL optionsforce
- force the update when options are equals
-
updateTrafficShapingOptions
public void updateTrafficShapingOptions(io.vertx.core.net.TrafficShapingOptions options) - Parameters:
options
- the new traffic shaping options
-
listen
Likelisten(int, java.lang.String)
but 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
. Don't forget to subscribe on it to trigger the operation.- Parameters:
port
- the port to listen onhost
- the host to listen on- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
listenAndAwait
Blocking variant oflisten(int,String)
.This method waits 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 a RuntimeException).
- Parameters:
port
- the port to listen onhost
- the host to listen on- Returns:
- the HttpServer instance produced by the operation.
-
listenAndForget
Variant oflisten(int,String)
that ignores the result of the operation.This method subscribes on the result of
listen(int,String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromlisten(int,String)
but you don't need to compose it with other operations.- Parameters:
port
- the port to listen onhost
- the host to listen on- Returns:
- the instance of HttpServer to chain method calls.
-
listen
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
. Don't forget to subscribe on it to trigger the operation.- Parameters:
address
- the address to listen on- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
listenAndAwait
Blocking variant oflisten(io.vertx.mutiny.core.net.SocketAddress)
.This method waits 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 a RuntimeException).
- Parameters:
address
- the address to listen on- Returns:
- the HttpServer instance produced by the operation.
-
listenAndForget
Variant oflisten(io.vertx.mutiny.core.net.SocketAddress)
that ignores the result of the operation.This method subscribes on the result of
listen(io.vertx.mutiny.core.net.SocketAddress)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromlisten(io.vertx.mutiny.core.net.SocketAddress)
but you don't need to compose it with other operations.- Parameters:
address
- the address to listen on- Returns:
- the instance of HttpServer to chain method calls.
-
listen
Likelisten(int, java.lang.String)
but 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
. Don't forget to subscribe on it to trigger the operation.- Parameters:
port
- the port to listen on- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
listenAndAwait
Blocking variant oflisten(int)
.This method waits 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 a RuntimeException).
- Parameters:
port
- the port to listen on- Returns:
- the HttpServer instance produced by the operation.
-
listenAndForget
Variant oflisten(int)
that ignores the result of the operation.This method subscribes on the result of
listen(int)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromlisten(int)
but you don't need to compose it with other operations.- Parameters:
port
- the port to listen on- Returns:
- the instance of HttpServer to chain method calls.
-
listen
Likelisten(int, java.lang.String)
but 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
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
listenAndAwait
Blocking variant oflisten(int, java.lang.String)
.This method waits 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 a RuntimeException).
- Returns:
- the HttpServer instance produced by the operation.
-
listenAndForget
Variant oflisten(int, java.lang.String)
that ignores the result of the operation.This method subscribes on the result of
listen(int, java.lang.String)
, but discards the outcome (item or failure). This method is useful to trigger the asynchronous operation fromlisten(int, java.lang.String)
but you don't need to compose it with other operations.- Returns:
- the instance of HttpServer to chain method calls.
-
close
Likeclose()
but supplying a handler that will be called when the server is actually closed (or has failed).Unlike the bare Vert.x variant, this method returns a
Uni
. Don't forget to subscribe on it to trigger the operation.- Returns:
- the
uni
firing the result of the operation when completed, or a failure if the operation failed.
-
closeAndAwait
Blocking variant ofclose()
.This method waits 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 a RuntimeException).
- Returns:
- the Void instance produced by the operation.
-
closeAndForget
public void closeAndForget() -
actualPort
public int actualPort()- Returns:
- the actual port the server is listening on.
-
newInstance
-
#requestHandler(Handler)