public class HttpServerImpl extends Object implements HttpServer, Closeable, MetricsProvider
| Constructor and Description |
|---|
HttpServerImpl(VertxInternal vertx,
HttpServerOptions options) |
| 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>> done)
Like
HttpServer.close() but supplying a handler that will be called when the server is actually closed (or has failed). |
void |
closeAll(Handler<AsyncResult<Void>> handler)
Internal method that closes all servers when Vert.x is closing
|
HttpServer |
connectionHandler(Handler<HttpConnection> handler)
Set a connection handler for the server.
|
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.
|
protected void |
finalize() |
Metrics |
getMetrics()
Returns the metrics implementation.
|
SSLHelper |
getSslHelper() |
boolean |
isClosed() |
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
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(int, String) 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
HttpServer.listen(int) 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
HttpServer.listen(int, String) 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).
|
Handler<HttpServerRequest> |
requestHandler() |
HttpServer |
requestHandler(Handler<HttpServerRequest> handler)
Set the request handler for the server to
requestHandler. |
ReadStream<HttpServerRequest> |
requestStream()
Return the request stream for the server.
|
Handler<ServerWebSocket> |
websocketHandler() |
Handler<ServerWebSocket> |
webSocketHandler() |
HttpServer |
websocketHandler(Handler<ServerWebSocket> handler)
Set the WebSocket handler for the server to
wsHandler. |
HttpServer |
webSocketHandler(Handler<ServerWebSocket> handler)
Set the WebSocket handler for the server to
wsHandler. |
ReadStream<ServerWebSocket> |
websocketStream()
Return the WebSocket stream for the server.
|
ReadStream<ServerWebSocket> |
webSocketStream()
Return the WebSocket stream for the server.
|
public HttpServerImpl(VertxInternal vertx, HttpServerOptions options)
public HttpServer requestHandler(Handler<HttpServerRequest> handler)
HttpServerrequestHandler. As HTTP requests are received by the server,
instances of HttpServerRequest will be created and passed to this handler.requestHandler in interface HttpServerpublic ReadStream<HttpServerRequest> requestStream()
HttpServerHttpServerRequest will be created and passed to the stream ReadStream.handler(io.vertx.core.Handler).requestStream in interface HttpServerpublic HttpServer webSocketHandler(Handler<ServerWebSocket> handler)
HttpServerwsHandler. If a WebSocket connect handshake is successful a
new ServerWebSocket instance will be created and passed to the handler.webSocketHandler in interface HttpServerpublic HttpServer websocketHandler(Handler<ServerWebSocket> handler)
HttpServerwsHandler. If a WebSocket connect handshake is successful a
new ServerWebSocket instance will be created and passed to the handler.websocketHandler in interface HttpServerpublic Handler<HttpServerRequest> requestHandler()
requestHandler in interface HttpServerpublic HttpServer connectionHandler(Handler<HttpConnection> handler)
HttpServerconnectionHandler in interface HttpServerpublic HttpServer exceptionHandler(Handler<Throwable> handler)
HttpServerexceptionHandler in interface HttpServerhandler - the handler to setpublic Handler<ServerWebSocket> websocketHandler()
websocketHandler in interface HttpServerpublic Handler<ServerWebSocket> webSocketHandler()
webSocketHandler in interface HttpServerpublic ReadStream<ServerWebSocket> websocketStream()
HttpServerServerWebSocket instance will be created and passed to the stream ReadStream.handler(io.vertx.core.Handler).websocketStream in interface HttpServerpublic ReadStream<ServerWebSocket> webSocketStream()
HttpServerServerWebSocket instance will be created and passed to the stream ReadStream.handler(io.vertx.core.Handler).webSocketStream in interface HttpServerpublic HttpServer listen()
HttpServerHttpServerOptions 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.
listen in interface HttpServerpublic HttpServer listen(Handler<AsyncResult<HttpServer>> listenHandler)
HttpServerHttpServer.listen() but supplying a handler that will be called when the server is actually listening (or has failed).listen in interface HttpServerlistenHandler - the listen handlerpublic HttpServer listen(int port, String host)
HttpServerHttpServerOptions 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.
listen in interface HttpServerport - the port to listen onhost - the host to listen onpublic HttpServer listen(int port)
HttpServerHttpServer.listen(int, String) 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.listen in interface HttpServerport - the port to listen onpublic HttpServer listen(int port, Handler<AsyncResult<HttpServer>> listenHandler)
HttpServerHttpServer.listen(int) but supplying a handler that will be called when the server is actually listening (or has failed).listen in interface HttpServerport - the port to listen onlistenHandler - the listen handlerpublic HttpServer listen(int port, String host, Handler<AsyncResult<HttpServer>> listenHandler)
HttpServerHttpServer.listen(int, String) but supplying a handler that will be called when the server is actually
listening (or has failed).listen in interface HttpServerport - the port to listen onhost - the host to listen onlistenHandler - the listen handlerpublic HttpServer listen(SocketAddress address, Handler<AsyncResult<HttpServer>> listenHandler)
HttpServerlisten in interface HttpServeraddress - the address to listen onlistenHandler - the listen handlerpublic void closeAll(Handler<AsyncResult<Void>> handler)
public void close()
HttpServerThe close happens asynchronously and the server may not be closed until some time after the call has returned.
close in interface HttpServerpublic void close(Handler<AsyncResult<Void>> done)
HttpServerHttpServer.close() but supplying a handler that will be called when the server is actually closed (or has failed).close in interface Closeableclose in interface HttpServerdone - the handlerpublic boolean isClosed()
public Metrics getMetrics()
MetricsProvidergetMetrics in interface MetricsProviderpublic boolean isMetricsEnabled()
MeasuredisMetricsEnabled in interface Measuredtrue if metrics are enabledpublic SSLHelper getSslHelper()
public int actualPort()
HttpServeractualPort in interface HttpServerCopyright © 2020. All rights reserved.