public class HttpServerImpl extends Object implements HttpServer, Closeable, MetricsProvider
Modifier and Type | Class and Description |
---|---|
class |
HttpServerImpl.ServerHandler |
Constructor and Description |
---|
HttpServerImpl(VertxInternal vertx,
HttpServerOptions options) |
Modifier and Type | Method and Description |
---|---|
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). |
protected void |
finalize() |
Metrics |
getMetrics()
Returns the metrics implementation.
|
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). |
Handler<HttpServerRequest> |
requestHandler() |
HttpServer |
requestHandler(Handler<HttpServerRequest> handler)
Set the request handler for the server to
requestHandler . |
HttpServerRequestStream |
requestStream()
Return the request stream for the server.
|
Handler<ServerWebSocket> |
websocketHandler() |
HttpServer |
websocketHandler(Handler<ServerWebSocket> handler)
Set the websocket handler for the server to
wsHandler . |
ServerWebSocketStream |
websocketStream()
Return the websocket stream for the server.
|
public HttpServerImpl(VertxInternal vertx, HttpServerOptions options)
public HttpServer requestHandler(Handler<HttpServerRequest> handler)
HttpServer
requestHandler
. As HTTP requests are received by the server,
instances of HttpServerRequest
will be created and passed to this handler.requestHandler
in interface HttpServer
public HttpServerRequestStream requestStream()
HttpServer
HttpServerRequest
will be created and passed to the stream ReadStream.handler(io.vertx.core.Handler)
.requestStream
in interface HttpServer
public HttpServer websocketHandler(Handler<ServerWebSocket> handler)
HttpServer
wsHandler
. If a websocket connect handshake is successful a
new ServerWebSocket
instance will be created and passed to the handler.websocketHandler
in interface HttpServer
public Handler<HttpServerRequest> requestHandler()
requestHandler
in interface HttpServer
public Handler<ServerWebSocket> websocketHandler()
websocketHandler
in interface HttpServer
public ServerWebSocketStream websocketStream()
HttpServer
ServerWebSocket
instance will be created and passed to the stream ReadStream.handler(io.vertx.core.Handler)
.websocketStream
in interface HttpServer
public HttpServer listen()
HttpServer
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.
listen
in interface HttpServer
public HttpServer listen(Handler<AsyncResult<HttpServer>> listenHandler)
HttpServer
HttpServer.listen()
but supplying a handler that will be called when the server is actually listening (or has failed).listen
in interface HttpServer
listenHandler
- the listen handlerpublic HttpServer listen(int port, String host)
HttpServer
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.
listen
in interface HttpServer
port
- the port to listen onhost
- the host to listen onpublic HttpServer listen(int port)
HttpServer
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.listen
in interface HttpServer
port
- the port to listen onpublic HttpServer listen(int port, Handler<AsyncResult<HttpServer>> listenHandler)
HttpServer
HttpServer.listen(int)
but supplying a handler that will be called when the server is actually listening (or has failed).listen
in interface HttpServer
port
- the port to listen onlistenHandler
- the listen handlerpublic HttpServer listen(int port, String host, Handler<AsyncResult<HttpServer>> listenHandler)
HttpServer
HttpServer.listen(int, String)
but supplying a handler that will be called when the server is actually
listening (or has failed).listen
in interface HttpServer
port
- the port to listen onhost
- the host to listen onlistenHandler
- the listen handlerpublic void close()
HttpServer
The close happens asynchronously and the server may not be closed until some time after the call has returned.
close
in interface HttpServer
public void close(Handler<AsyncResult<Void>> done)
HttpServer
HttpServer.close()
but supplying a handler that will be called when the server is actually closed (or has failed).close
in interface HttpServer
close
in interface Closeable
done
- the handlerpublic Metrics getMetrics()
MetricsProvider
getMetrics
in interface MetricsProvider
public boolean isMetricsEnabled()
Measured
isMetricsEnabled
in interface Measured
Copyright © 2015. All Rights Reserved.