An HTTP and WebSockets server

If an instance is instantiated from an event loop then the handlers of the instance will always be called on that same event loop. If an instance is instantiated from some other arbitrary Java thread then an event loop will be assigned to the instance and used when any of its handlers are called.

Instances of HttpServer are thread-safe.

By: Julien Viet

no subtypes hierarchy

HttpServer(Vertx vertx, HttpServer delegate)
compressionSupportedshared Boolean compressionSupported

Returns true if the HttpServer should compress the http response if the connected client supports it.

maxWebSocketFrameSizeshared Integer maxWebSocketFrameSize

The maximum websocket frame size in bytes.

webSocketSubProtocolsshared String[] webSocketSubProtocols

Returns all the supported subprotocols. An empty sequence is returned if non are supported. This is the default.

Inherited Attributes
Attributes inherited from: NetworkBase
Attributes inherited from: Object
hash, string
Attributes inherited from: ServerBase
closeshared Promise<Anything> close()

Close the server. Any open HTTP connections will be closed. The returned promise is resolved when the close is complete.

createSockJSServershared SockJSServer createSockJSServer()
listenshared Promise<HttpServer> listen(Integer port, String? hostName = null)

Tell the server to start listening on all available interfaces and port port. Be aware this is an async operation and the server may not bound on return of the method. The returned promise is resolved when the server is listening

  • hostName = null
requestHandlershared HttpServer requestHandler(void onRequest(HttpServerRequest req))

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

websocketHandlershared HttpServer websocketHandler(void onConnect(ServerWebSocket websocket))

Set the websocket handler for the server to onConnect(). If a websocket connect handshake is successful a new ServerWebSocket instance will be created and passed to onConnect().

Inherited Methods
Methods inherited from: Object