vertx / io.vertx.reactivex.core.http / HttpServer

HttpServer

open class HttpServer : Measured

An HTTP and WebSockets server.

You receive HTTP requests by providing a io.vertx.reactivex.core.http.HttpServer#requestHandler. As requests arrive on the server the handler will be called with the requests.

You receive WebSockets by providing a io.vertx.reactivex.core.http.HttpServer#websocketHandler. As WebSocket connections arrive on the server, the WebSocket is passed to the handler.

NOTE: This class has been automatically generated from the io.vertx.core.http.HttpServer non RX-ified interface using Vert.x codegen.

Constructors

<init>

HttpServer(delegate: HttpServer)

Properties

__TYPE_ARG

static val __TYPE_ARG: TypeArg<HttpServer>

Functions

actualPort

open fun actualPort(): Int

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

close

open fun close(): Unit

Close the server. Any open HTTP connections will be closed.

The close happens asynchronously and the server may not be closed until some time after the call has returned.

open fun close(completionHandler: Handler<AsyncResult<Void>>): Unit

Like io.vertx.reactivex.core.http.HttpServer#close but supplying a handler that will be called when the server is actually closed (or has failed).

connectionHandler

open fun connectionHandler(handler: Handler<HttpConnection>): HttpServer

Set a connection handler for the server.

equals

open fun equals(other: Any?): Boolean

exceptionHandler

open fun exceptionHandler(handler: Handler<Throwable>): HttpServer

Set an exception handler called for socket errors happening before the HTTP connection is established, e.g during the TLS handshake.

getDelegate

open fun getDelegate(): HttpServer

hashCode

open fun hashCode(): Int

isMetricsEnabled

open fun isMetricsEnabled(): Boolean

Whether the metrics are enabled for this measured object

listen

open fun listen(): HttpServer

Tell the server to start listening. The server will listen on the port and host specified in the io.vertx.core.http.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.

open fun listen(port: Int, host: String): HttpServer

Tell the server to start listening. The server will listen on the port and host specified here, ignoring any value set in the io.vertx.core.http.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.

open fun listen(port: Int, host: String, listenHandler: Handler<AsyncResult<HttpServer>>): HttpServer
open fun listen(port: Int, listenHandler: Handler<AsyncResult<HttpServer>>): HttpServer
open fun listen(listenHandler: Handler<AsyncResult<HttpServer>>): HttpServer

Like io.vertx.reactivex.core.http.HttpServer#listen but supplying a handler that will be called when the server is actually listening (or has failed).

open fun listen(port: Int): HttpServer

Like io.vertx.reactivex.core.http.HttpServer#listen but the server will listen on host "0.0.0.0" and port specified here ignoring any value in the io.vertx.core.http.HttpServerOptions that was used when creating the server.

newInstance

open static fun newInstance(arg: HttpServer): HttpServer

requestHandler

open fun requestHandler(handler: Handler<HttpServerRequest>): HttpServer

Set the request handler for the server to requestHandler. As HTTP requests are received by the server, instances of io.vertx.reactivex.core.http.HttpServerRequest will be created and passed to this handler.

requestStream

open fun requestStream(): ReadStream<HttpServerRequest>

Return the request stream for the server. As HTTP requests are received by the server, instances of io.vertx.reactivex.core.http.HttpServerRequest will be created and passed to the stream .

rxClose

open fun rxClose(): Completable

Like io.vertx.reactivex.core.http.HttpServer#close but supplying a handler that will be called when the server is actually closed (or has failed).

rxListen

open fun rxListen(port: Int, host: String): Single<HttpServer>
open fun rxListen(port: Int): Single<HttpServer>
open fun rxListen(): Single<HttpServer>

Like io.vertx.reactivex.core.http.HttpServer#listen but supplying a handler that will be called when the server is actually listening (or has failed).

toString

open fun toString(): String

websocketHandler

open fun websocketHandler(handler: Handler<ServerWebSocket>): HttpServer

Set the websocket handler for the server to wsHandler. If a websocket connect handshake is successful a new io.vertx.reactivex.core.http.ServerWebSocket instance will be created and passed to the handler.

websocketStream

open fun websocketStream(): ReadStream<ServerWebSocket>

Return the websocket stream for the server. If a websocket connect handshake is successful a new io.vertx.reactivex.core.http.ServerWebSocket instance will be created and passed to the stream .