public class HttpServer extends Object implements Measured
You receive HTTP requests by providing a requestHandler(io.vertx.core.Handler<io.vertx.reactivex.core.http.HttpServerRequest>)
. As requests arrive on the server the handler
will be called with the requests.
You receive WebSockets by providing a webSocketHandler(io.vertx.core.Handler<io.vertx.reactivex.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.Modifier and Type | Field and Description |
---|---|
static io.vertx.lang.rx.TypeArg<HttpServer> |
__TYPE_ARG |
Constructor and Description |
---|
HttpServer(HttpServer delegate) |
HttpServer(Object delegate) |
Modifier and Type | Method and Description |
---|---|
int |
actualPort()
The actual port the server is listening on.
|
void |
close()
Like
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but supplying a handler that will be called when the server is actually closed (or has failed). |
void |
close(Handler<AsyncResult<Void>> completionHandler)
Like
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but supplying a handler that will be called when the server is actually closed (or has failed). |
HttpServer |
connectionHandler(Handler<HttpConnection> handler)
Set a connection handler for the server.
|
boolean |
equals(Object o) |
HttpServer |
exceptionHandler(Handler<Throwable> handler)
Set an exception handler called for socket errors happening before the HTTP connection
is established, e.g during the TLS handshake.
|
HttpServer |
getDelegate() |
int |
hashCode() |
HttpServer |
invalidRequestHandler(Handler<HttpServerRequest> handler)
Set a
handler for handling invalid requests. |
boolean |
isMetricsEnabled()
Whether the metrics are enabled for this measured object
|
HttpServer |
listen()
Like
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>) but supplying a handler that will be called when the server is actually listening (or has failed). |
HttpServer |
listen(Handler<AsyncResult<HttpServer>> listenHandler)
Like
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>) but supplying a handler that will be called when the server is actually listening (or has failed). |
HttpServer |
listen(int port)
Like
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>) but supplying a handler that will be called when the server is actually listening (or has failed). |
HttpServer |
listen(int port,
Handler<AsyncResult<HttpServer>> listenHandler)
Like
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>) but supplying a handler that will be called when the server is actually listening (or has failed). |
HttpServer |
listen(int port,
String host)
Like
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>) but supplying a handler that will be called when the server is actually
listening (or has failed). |
HttpServer |
listen(int port,
String host,
Handler<AsyncResult<HttpServer>> listenHandler)
Like
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>) but supplying a handler that will be called when the server is actually
listening (or has failed). |
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 |
listen(SocketAddress address,
Handler<AsyncResult<HttpServer>> listenHandler)
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(HttpServer arg) |
HttpServer |
requestHandler(Handler<HttpServerRequest> handler)
Set the request handler for the server to
requestHandler . |
ReadStream<HttpServerRequest> |
requestStream()
Deprecated.
|
Completable |
rxClose()
Like
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>) but supplying a handler that will be called when the server is actually closed (or has failed). |
Single<HttpServer> |
rxListen()
Like
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>) but supplying a handler that will be called when the server is actually listening (or has failed). |
Single<HttpServer> |
rxListen(int port)
Like
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>) but supplying a handler that will be called when the server is actually listening (or has failed). |
Single<HttpServer> |
rxListen(int port,
String host)
Like
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>) but supplying a handler that will be called when the server is actually
listening (or has failed). |
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).
|
Single<Boolean> |
rxUpdateSSLOptions(SSLOptions options)
Like
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>) but supplying a handler that will be called when the update
happened (or has failed). |
Single<Boolean> |
rxUpdateSSLOptions(SSLOptions options,
boolean force)
Like
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>) but supplying a handler that will be called when the update
happened (or has failed). |
String |
toString() |
void |
updateSSLOptions(SSLOptions options)
Like
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>) but supplying a handler that will be called when the update
happened (or has failed). |
void |
updateSSLOptions(SSLOptions options,
boolean force)
Like
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>) but supplying a handler that will be called when the update
happened (or has failed). |
void |
updateSSLOptions(SSLOptions options,
boolean force,
Handler<AsyncResult<Boolean>> handler)
Like
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>) but supplying a handler that will be called when the update
happened (or has failed). |
void |
updateSSLOptions(SSLOptions options,
Handler<AsyncResult<Boolean>> handler)
Like
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>) but supplying a handler that will be called when the update
happened (or has failed). |
void |
updateTrafficShapingOptions(TrafficShapingOptions options)
Update traffic shaping options
options , the update happens if valid values are passed for traffic
shaping options. |
HttpServer |
webSocketHandler(Handler<ServerWebSocket> handler)
Set the WebSocket handler for the server to
wsHandler . |
HttpServer |
webSocketHandshakeHandler(Handler<ServerWebSocketHandshake> handler)
Set a handler for WebSocket handshake.
|
ReadStream<ServerWebSocket> |
webSocketStream()
Deprecated.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
newInstance
public static final io.vertx.lang.rx.TypeArg<HttpServer> __TYPE_ARG
public HttpServer(HttpServer delegate)
public HttpServer(Object delegate)
public HttpServer getDelegate()
getDelegate
in interface Measured
public boolean isMetricsEnabled()
isMetricsEnabled
in interface Measured
true
if metrics are enabled@Deprecated public ReadStream<HttpServerRequest> requestStream()
HttpServerRequest
will be created and passed to the stream ReadStream.handler(io.vertx.core.Handler<T>)
.public HttpServer requestHandler(Handler<HttpServerRequest> handler)
requestHandler
. As HTTP requests are received by the server,
instances of HttpServerRequest
will be created and passed to this handler.handler
- public HttpServer invalidRequestHandler(Handler<HttpServerRequest> handler)
handler
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.reactivex.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.
handler
- public HttpServer connectionHandler(Handler<HttpConnection> handler)
handler
- public HttpServer exceptionHandler(Handler<Throwable> handler)
handler
- the handler to set@Deprecated public ReadStream<ServerWebSocket> webSocketStream()
ServerWebSocket
instance will be created and passed to the stream ReadStream.handler(io.vertx.core.Handler<T>)
.public HttpServer webSocketHandler(Handler<ServerWebSocket> handler)
wsHandler
. If a WebSocket connect handshake is successful a
new ServerWebSocket
instance will be created and passed to the handler.handler
- public HttpServer webSocketHandshakeHandler(Handler<ServerWebSocketHandshake> handler)
When an inbound HTTP request presents a WebSocket upgrade, this handler is called first. The handler
can chose to ServerWebSocketHandshake.accept()
or ServerWebSocketHandshake.reject()
the request.
Setting no handler, implicitly accepts any HTTP request connection presenting an upgrade header and upgrades it to a WebSocket.
handler
- public void updateSSLOptions(SSLOptions options, Handler<AsyncResult<Boolean>> handler)
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update
happened (or has failed).options
- the new SSL optionshandler
- the update handlerpublic void updateSSLOptions(SSLOptions options)
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update
happened (or has failed).options
- the new SSL optionspublic Single<Boolean> rxUpdateSSLOptions(SSLOptions options)
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update
happened (or has failed).options
- the new SSL optionspublic void updateSSLOptions(SSLOptions options, boolean force, Handler<AsyncResult<Boolean>> handler)
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update
happened (or has failed).options
- the new SSL optionsforce
- force the update when options are equalshandler
- the update handlerpublic void updateSSLOptions(SSLOptions options, boolean force)
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update
happened (or has failed).options
- the new SSL optionsforce
- force the update when options are equalspublic Single<Boolean> rxUpdateSSLOptions(SSLOptions options, boolean force)
updateSSLOptions(io.vertx.core.net.SSLOptions, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>>)
but supplying a handler that will be called when the update
happened (or has failed).options
- the new SSL optionsforce
- force the update when options are equalspublic void updateTrafficShapingOptions(TrafficShapingOptions options)
options
, 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.options
- the new traffic shaping optionspublic HttpServer listen(int port, String host, Handler<AsyncResult<HttpServer>> listenHandler)
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>)
but supplying a handler that will be called when the server is actually
listening (or has failed).port
- the port to listen onhost
- the host to listen onlistenHandler
- the listen handlerpublic HttpServer listen(int port, String host)
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>)
but supplying a handler that will be called when the server is actually
listening (or has failed).port
- the port to listen onhost
- the host to listen onpublic Single<HttpServer> rxListen(int port, String host)
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>)
but supplying a handler that will be called when the server is actually
listening (or has failed).port
- the port to listen onhost
- the host to listen onpublic HttpServer listen(SocketAddress address, Handler<AsyncResult<HttpServer>> listenHandler)
address
- the address to listen onlistenHandler
- the listen handlerpublic HttpServer listen(SocketAddress address)
address
- the address to listen onpublic Single<HttpServer> rxListen(SocketAddress address)
address
- the address to listen onpublic HttpServer listen(int port, Handler<AsyncResult<HttpServer>> listenHandler)
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>)
but supplying a handler that will be called when the server is actually listening (or has failed).port
- the port to listen onlistenHandler
- the listen handlerpublic HttpServer listen(int port)
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>)
but supplying a handler that will be called when the server is actually listening (or has failed).port
- the port to listen onpublic Single<HttpServer> rxListen(int port)
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>)
but supplying a handler that will be called when the server is actually listening (or has failed).port
- the port to listen onpublic HttpServer listen(Handler<AsyncResult<HttpServer>> listenHandler)
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>)
but supplying a handler that will be called when the server is actually listening (or has failed).listenHandler
- the listen handlerpublic HttpServer listen()
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>)
but supplying a handler that will be called when the server is actually listening (or has failed).public Single<HttpServer> rxListen()
listen(int, java.lang.String, io.vertx.core.Handler<io.vertx.core.AsyncResult<io.vertx.reactivex.core.http.HttpServer>>)
but supplying a handler that will be called when the server is actually listening (or has failed).public void close(Handler<AsyncResult<Void>> completionHandler)
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but supplying a handler that will be called when the server is actually closed (or has failed).completionHandler
- the handlerpublic void close()
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but supplying a handler that will be called when the server is actually closed (or has failed).public Completable rxClose()
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>>)
but supplying a handler that will be called when the server is actually closed (or has failed).public int actualPort()
public static HttpServer newInstance(HttpServer arg)
Copyright © 2024 Eclipse. All rights reserved.