public class HttpServer extends Object implements Measured
You receive HTTP requests by providing a requestHandler(io.vertx.core.Handler<io.vertx.rxjava.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.rxjava.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()
Close the server.
|
void |
close(Handler<AsyncResult<Void>> completionHandler)
Like
close() but supplying a handler that will be called when the server is actually closed (or has failed). |
Observable<Void> |
closeObservable()
Deprecated.
use
rxClose() instead |
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() |
boolean |
isMetricsEnabled()
Whether the metrics are enabled for this measured object
|
HttpServer |
listen()
Tell the server to start listening.
|
HttpServer |
listen(Handler<AsyncResult<HttpServer>> listenHandler)
Like
listen() but supplying a handler that will be called when the server is actually listening (or has failed). |
HttpServer |
listen(int port)
Like
listen() but the server will listen on host "0.0.0.0" and port specified here ignoring
any value in the HttpServerOptions that was used when creating the server. |
HttpServer |
listen(int port,
Handler<AsyncResult<HttpServer>> listenHandler)
Like
listen() but supplying a handler that will be called when the server is actually listening (or has failed). |
HttpServer |
listen(int port,
String host)
Tell the server to start listening.
|
HttpServer |
listen(int port,
String host,
Handler<AsyncResult<HttpServer>> listenHandler)
Like
listen() but 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).
|
Observable<HttpServer> |
listenObservable()
Deprecated.
use
rxListen(int, java.lang.String) instead |
Observable<HttpServer> |
listenObservable(int port)
Deprecated.
use
rxListen(int, java.lang.String) instead |
Observable<HttpServer> |
listenObservable(int port,
String host)
Deprecated.
use
rxListen(int, java.lang.String) instead |
Observable<HttpServer> |
listenObservable(SocketAddress address)
Deprecated.
use
rxListen(int, java.lang.String) instead |
static HttpServer |
newInstance(HttpServer arg) |
HttpServer |
requestHandler(Handler<HttpServerRequest> handler)
Set the request handler for the server to
requestHandler . |
ReadStream<HttpServerRequest> |
requestStream()
Return the request stream for the server.
|
Single<Void> |
rxClose()
Like
close() but supplying a handler that will be called when the server is actually closed (or has failed). |
Single<HttpServer> |
rxListen()
Like
listen() but supplying a handler that will be called when the server is actually listening (or has failed). |
Single<HttpServer> |
rxListen(int port)
Like
listen() 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() 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).
|
String |
toString() |
HttpServer |
websocketHandler(Handler<ServerWebSocket> handler)
Deprecated.
|
HttpServer |
webSocketHandler(Handler<ServerWebSocket> handler)
Set the WebSocket handler for the server to
wsHandler . |
ReadStream<ServerWebSocket> |
websocketStream()
Deprecated.
|
ReadStream<ServerWebSocket> |
webSocketStream()
Return the WebSocket stream for the server.
|
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 enabledpublic ReadStream<HttpServerRequest> requestStream()
HttpServerRequest
will be created and passed to the stream .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 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 .public ReadStream<ServerWebSocket> webSocketStream()
ServerWebSocket
instance will be created and passed to the stream .@Deprecated 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 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 listen()
HttpServerOptions
that 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.
public HttpServer listen(int port, String host)
HttpServerOptions
that 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.
port
- the port to listen onhost
- the host to listen onpublic HttpServer listen(int port, String host, Handler<AsyncResult<HttpServer>> listenHandler)
listen()
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 handler@Deprecated public Observable<HttpServer> listenObservable(int port, String host)
rxListen(int, java.lang.String)
insteadlisten()
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()
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 handler@Deprecated public Observable<HttpServer> listenObservable(SocketAddress address)
rxListen(int, java.lang.String)
insteadaddress
- the address to listen onpublic Single<HttpServer> rxListen(SocketAddress address)
address
- the address to listen onpublic HttpServer listen(int port)
listen()
but the server will listen on host "0.0.0.0" and port specified here ignoring
any value in the HttpServerOptions
that was used when creating the server.port
- the port to listen onpublic HttpServer listen(int port, Handler<AsyncResult<HttpServer>> listenHandler)
listen()
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 handler@Deprecated public Observable<HttpServer> listenObservable(int port)
rxListen(int, java.lang.String)
insteadlisten()
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()
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()
but supplying a handler that will be called when the server is actually listening (or has failed).listenHandler
- the listen handler@Deprecated public Observable<HttpServer> listenObservable()
rxListen(int, java.lang.String)
insteadlisten()
but supplying a handler that will be called when the server is actually listening (or has failed).public Single<HttpServer> rxListen()
listen()
but supplying a handler that will be called when the server is actually listening (or has failed).public void close()
The close happens asynchronously and the server may not be closed until some time after the call has returned.
public void close(Handler<AsyncResult<Void>> completionHandler)
close()
but supplying a handler that will be called when the server is actually closed (or has failed).completionHandler
- the handler@Deprecated public Observable<Void> closeObservable()
rxClose()
insteadclose()
but supplying a handler that will be called when the server is actually closed (or has failed).public Single<Void> rxClose()
close()
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 © 2023 Eclipse. All rights reserved.