Package io.vertx.rxjava3.core.http
Class HttpServer
- java.lang.Object
-
- io.vertx.rxjava3.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(io.vertx.core.Handler<io.vertx.rxjava3.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(io.vertx.core.Handler<io.vertx.rxjava3.core.http.ServerWebSocket>)
. As WebSocket connections arrive on the server, the WebSocket is passed to the handler.original
non RX-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 Deprecated Methods Modifier and Type Method Description int
actualPort()
The actual port the server is listening on.io.reactivex.rxjava3.core.Completable
close()
Likeclose()
but supplying a handler that will be called when the server is actually closed (or has failed).HttpServer
connectionHandler(io.vertx.core.Handler<HttpConnection> handler)
Set a connection handler for the server.boolean
equals(Object o)
HttpServer
exceptionHandler(io.vertx.core.Handler<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.HttpServer
getDelegate()
int
hashCode()
HttpServer
invalidRequestHandler(io.vertx.core.Handler<HttpServerRequest> handler)
Set ahandler
for handling invalid requests.boolean
isMetricsEnabled()
Whether the metrics are enabled for this measured objectio.reactivex.rxjava3.core.Single<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.reactivex.rxjava3.core.Single<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.reactivex.rxjava3.core.Single<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.reactivex.rxjava3.core.Single<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).static HttpServer
newInstance(io.vertx.core.http.HttpServer arg)
HttpServer
requestHandler(io.vertx.core.Handler<HttpServerRequest> handler)
Set the request handler for the server torequestHandler
.ReadStream<HttpServerRequest>
requestStream()
Deprecated.io.reactivex.rxjava3.core.Completable
rxClose()
Likeclose()
but supplying a handler that will be called when the server is actually closed (or has failed).io.reactivex.rxjava3.core.Single<HttpServer>
rxListen()
Likelisten(int, java.lang.String)
but supplying a handler that will be called when the server is actually listening (or has failed).io.reactivex.rxjava3.core.Single<HttpServer>
rxListen(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.reactivex.rxjava3.core.Single<HttpServer>
rxListen(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.reactivex.rxjava3.core.Single<HttpServer>
rxListen(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).io.reactivex.rxjava3.core.Single<Boolean>
rxUpdateSSLOptions(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.reactivex.rxjava3.core.Single<Boolean>
rxUpdateSSLOptions(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).String
toString()
io.reactivex.rxjava3.core.Single<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.reactivex.rxjava3.core.Single<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).void
updateTrafficShapingOptions(io.vertx.core.net.TrafficShapingOptions options)
Update traffic shaping optionsoptions
, the update happens if valid values are passed for traffic shaping options.HttpServer
webSocketHandler(io.vertx.core.Handler<ServerWebSocket> handler)
Set the WebSocket handler for the server towsHandler
.ReadStream<ServerWebSocket>
webSocketStream()
Deprecated.
-
-
-
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()
Whether the metrics are enabled for this measured object- Specified by:
isMetricsEnabled
in interfaceMeasured
- Returns:
true
if metrics are enabled
-
requestStream
@Deprecated public ReadStream<HttpServerRequest> requestStream()
Deprecated.Return the request stream for the server. As HTTP requests are received by the server, instances ofHttpServerRequest
will be created and passed to the streamReadStream.handler(io.vertx.core.Handler<T>)
.- Returns:
- the request stream
-
requestHandler
public HttpServer requestHandler(io.vertx.core.Handler<HttpServerRequest> handler)
Set the request handler for the server torequestHandler
. As HTTP requests are received by the server, instances ofHttpServerRequest
will be created and passed to this handler.- Parameters:
handler
-- Returns:
- a reference to this, so the API can be used fluently
-
invalidRequestHandler
public HttpServer invalidRequestHandler(io.vertx.core.Handler<HttpServerRequest> handler)
Set ahandler
for 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.io.vertx.rxjava3.core.http.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
is used.- Parameters:
handler
-- Returns:
- a reference to this, so the API can be used fluently
-
connectionHandler
public HttpServer connectionHandler(io.vertx.core.Handler<HttpConnection> handler)
Set a connection handler for the server.
The handler will always be called on the event-loop thread.- Parameters:
handler
-- Returns:
- a reference to this, so the API can be used fluently
-
exceptionHandler
public HttpServer exceptionHandler(io.vertx.core.Handler<Throwable> handler)
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
-
webSocketStream
@Deprecated public ReadStream<ServerWebSocket> webSocketStream()
Deprecated.Return the WebSocket stream for the server. If a WebSocket connect handshake is successful a newServerWebSocket
instance will be created and passed to the streamReadStream.handler(io.vertx.core.Handler<T>)
.- Returns:
- the WebSocket stream
-
webSocketHandler
public HttpServer webSocketHandler(io.vertx.core.Handler<ServerWebSocket> handler)
Set the WebSocket handler for the server towsHandler
. If a WebSocket connect handshake is successful a newServerWebSocket
instance will be created and passed to the handler.- Parameters:
handler
-- Returns:
- a reference to this, so the API can be used fluently
-
updateSSLOptions
public io.reactivex.rxjava3.core.Single<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).- Parameters:
options
- the new SSL options- Returns:
-
rxUpdateSSLOptions
public io.reactivex.rxjava3.core.Single<Boolean> rxUpdateSSLOptions(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).- Parameters:
options
- the new SSL options- Returns:
-
updateSSLOptions
public io.reactivex.rxjava3.core.Single<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).- Parameters:
options
- the new SSL optionsforce
- force the update when options are equals- Returns:
-
rxUpdateSSLOptions
public io.reactivex.rxjava3.core.Single<Boolean> rxUpdateSSLOptions(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).- Parameters:
options
- the new SSL optionsforce
- force the update when options are equals- Returns:
-
updateTrafficShapingOptions
public void updateTrafficShapingOptions(io.vertx.core.net.TrafficShapingOptions options)
Update traffic shaping optionsoptions
, the update happens if valid values are passed for traffic shaping options. This update happens synchronously and at best effort for rate update to take effect immediately.- Parameters:
options
- the new traffic shaping options
-
listen
public io.reactivex.rxjava3.core.Single<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).- Parameters:
port
- the port to listen onhost
- the host to listen on- Returns:
-
rxListen
public io.reactivex.rxjava3.core.Single<HttpServer> rxListen(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).- Parameters:
port
- the port to listen onhost
- the host to listen on- Returns:
-
listen
public io.reactivex.rxjava3.core.Single<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).- Parameters:
address
- the address to listen on- Returns:
-
rxListen
public io.reactivex.rxjava3.core.Single<HttpServer> rxListen(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).- Parameters:
address
- the address to listen on- Returns:
-
listen
public io.reactivex.rxjava3.core.Single<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).- Parameters:
port
- the port to listen on- Returns:
-
rxListen
public io.reactivex.rxjava3.core.Single<HttpServer> rxListen(int port)
Likelisten(int, java.lang.String)
but supplying a handler that will be called when the server is actually listening (or has failed).- Parameters:
port
- the port to listen on- Returns:
-
listen
public io.reactivex.rxjava3.core.Single<HttpServer> listen()
Likelisten(int, java.lang.String)
but supplying a handler that will be called when the server is actually listening (or has failed).- Returns:
-
rxListen
public io.reactivex.rxjava3.core.Single<HttpServer> rxListen()
Likelisten(int, java.lang.String)
but supplying a handler that will be called when the server is actually listening (or has failed).- Returns:
-
close
public io.reactivex.rxjava3.core.Completable close()
Likeclose()
but supplying a handler that will be called when the server is actually closed (or has failed).- Returns:
-
rxClose
public io.reactivex.rxjava3.core.Completable rxClose()
Likeclose()
but supplying a handler that will be called when the server is actually closed (or has failed).- Returns:
-
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.
-
newInstance
public static HttpServer newInstance(io.vertx.core.http.HttpServer arg)
-
-