Class HttpServer
- java.lang.Object
-
- io.vertx.mutiny.core.http.HttpServer
-
- All Implemented Interfaces:
Measured
public class HttpServer extends Object implements Measured
An HTTP and WebSockets server.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
NOTE: This class has been automatically generated from thewebSocketHandler(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 Modifier and Type Field Description static TypeArg<HttpServer>
__TYPE_ARG
-
Constructor Summary
Constructors Constructor Description HttpServer(io.vertx.core.http.HttpServer delegate)
HttpServer(Object delegate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
actualPort()
io.smallrye.mutiny.Uni<Void>
close()
Likeclose()
but supplying a handler that will be called when the server is actually closed (or has failed).Void
closeAndAwait()
Blocking variant ofclose()
.void
closeAndForget()
Variant ofclose()
that ignores the result of the operation.HttpServer
connectionHandler(Consumer<HttpConnection> handler)
boolean
equals(Object o)
HttpServer
exceptionHandler(Consumer<Throwable> handler)
io.vertx.core.http.HttpServer
getDelegate()
int
hashCode()
HttpServer
invalidRequestHandler(Consumer<HttpServerRequest> handler)
boolean
isMetricsEnabled()
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>
listen(int port, String host)
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).HttpServer
listenAndAwait()
Blocking variant oflisten(int, java.lang.String)
.HttpServer
listenAndAwait(int port)
Blocking variant oflisten(int)
.HttpServer
listenAndAwait(int port, String host)
Blocking variant oflisten(int,String)
.HttpServer
listenAndAwait(SocketAddress address)
Blocking variant oflisten(io.vertx.mutiny.core.net.SocketAddress)
.HttpServer
listenAndForget()
Variant oflisten(int, java.lang.String)
that ignores the result of the operation.HttpServer
listenAndForget(int port)
Variant oflisten(int)
that ignores the result of the operation.HttpServer
listenAndForget(int port, String host)
Variant oflisten(int,String)
that ignores the result of the operation.HttpServer
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)
HttpServer
requestHandler(Consumer<HttpServerRequest> handler)
ReadStream<HttpServerRequest>
requestStream()
String
toString()
HttpServer
webSocketHandler(Consumer<ServerWebSocket> handler)
ReadStream<ServerWebSocket>
webSocketStream()
-
-
-
Field Detail
-
__TYPE_ARG
public static final TypeArg<HttpServer> __TYPE_ARG
-
-
Constructor Detail
-
HttpServer
public HttpServer(io.vertx.core.http.HttpServer delegate)
-
HttpServer
public HttpServer(Object delegate)
-
-
Method Detail
-
getDelegate
public io.vertx.core.http.HttpServer getDelegate()
- Specified by:
getDelegate
in interfaceMeasured
-
isMetricsEnabled
public boolean isMetricsEnabled()
- Specified by:
isMetricsEnabled
in interfaceMeasured
- Returns:
true
if metrics are enabled
-
requestStream
public ReadStream<HttpServerRequest> requestStream()
- Returns:
- the request stream
-
requestHandler
public HttpServer requestHandler(Consumer<HttpServerRequest> handler)
- Parameters:
handler
-- Returns:
-
invalidRequestHandler
public HttpServer invalidRequestHandler(Consumer<HttpServerRequest> handler)
- Parameters:
handler
-- Returns:
-
connectionHandler
public HttpServer connectionHandler(Consumer<HttpConnection> handler)
- Parameters:
handler
-- Returns:
-
exceptionHandler
public HttpServer exceptionHandler(Consumer<Throwable> handler)
- Parameters:
handler
- the handler to set- Returns:
-
webSocketStream
public ReadStream<ServerWebSocket> webSocketStream()
- Returns:
- the WebSocket stream
-
webSocketHandler
public HttpServer webSocketHandler(Consumer<ServerWebSocket> handler)
- Parameters:
handler
-- Returns:
-
listen
public io.smallrye.mutiny.Uni<HttpServer> listen(int port, String host)
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
public HttpServer listenAndAwait(int port, String host)
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
public HttpServer listenAndForget(int port, String host)
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
public 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).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
public HttpServer listenAndAwait(SocketAddress address)
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
public HttpServer listenAndForget(SocketAddress address)
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
public 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).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
public HttpServer listenAndAwait(int port)
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
public HttpServer listenAndForget(int port)
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
public 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).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
public HttpServer 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
public HttpServer 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
public io.smallrye.mutiny.Uni<Void> 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
public Void 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
public static HttpServer newInstance(io.vertx.core.http.HttpServer arg)
-
-