@groovy.transform.CompileStatic class HttpServer extends java.lang.Object
An HTTP and WebSockets server.
You receive HTTP requests by providing a HttpServer.requestHandler. As requests arrive on the server the handler will be called with the requests.
You receive WebSockets by providing a HttpServer.websocketHandler. As WebSocket connections arrive on the server, the WebSocket is passed to the handler.
Constructor and description |
---|
HttpServer
(java.lang.Object delegate) |
Type | Name and description | ||
---|---|---|---|
int |
actualPort() The actual port the server is listening on. |
||
void |
close() Close the server. |
||
void |
close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> completionHandler) Like HttpServer.close 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. |
||
java.lang.Object |
getDelegate() |
||
boolean |
isMetricsEnabled() Whether the metrics are enabled for this measured object |
||
HttpServer |
listen() Tell the server to start listening. |
||
HttpServer |
listen(int port, java.lang.String host) Tell the server to start listening. |
||
HttpServer |
listen(int port, java.lang.String host, io.vertx.core.Handler<io.vertx.core.AsyncResult<HttpServer>> listenHandler) Like HttpServer.listen but supplying a handler that will be called when the server is actually listening (or has failed). |
||
HttpServer |
listen(int port) Like HttpServer.listen but the server will listen on host "0.0.0.0" and port specified here ignoring any value in the | HttpServer |
listen(int port, io.vertx.core.Handler<io.vertx.core.AsyncResult<HttpServer>> listenHandler) Like HttpServer.listen but supplying a handler that will be called when the server is actually listening (or has failed). |
HttpServer |
listen(io.vertx.core.Handler<io.vertx.core.AsyncResult<HttpServer>> listenHandler) Like HttpServer.listen but supplying a handler that will be called when the server is actually listening (or has failed). |
||
HttpServer |
requestHandler(io.vertx.core.Handler<HttpServerRequest> handler) Set the request handler for the server to requestHandler . |
||
HttpServerRequestStream |
requestStream() Return the request stream for the server. |
||
HttpServer |
websocketHandler(io.vertx.core.Handler<ServerWebSocket> handler) Set the websocket handler for the server to wsHandler . |
||
ServerWebSocketStream |
websocketStream() Return the websocket stream for the server. |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
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 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.
Like HttpServer.close but supplying a handler that will be called when the server is actually closed (or has failed).
completionHandler
- the handlerSet a connection handler for the server.
Whether the metrics are enabled for this measured object
Tell the server to start listening. The server will listen on the port and host specified in the 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.
Tell the server to start listening. The server will listen on the port and host specified here, ignoring any value set in the 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 onLike HttpServer.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 handlerLike HttpServer.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 onLike HttpServer.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 handlerLike HttpServer.listen but supplying a handler that will be called when the server is actually listening (or has failed).
listenHandler
- the listen handler 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.
Return the request stream for the server. As HTTP requests are received by the server, instances of HttpServerRequest will be created and passed to the stream .
Set the websocket handler for the server to wsHandler
. If a websocket connect handshake is successful a
new ServerWebSocket instance will be created and passed to the handler.
Return the websocket stream for the server. If a websocket connect handshake is successful a new ServerWebSocket instance will be created and passed to the stream .