public interface HttpServer extends Measured
An HTTP and WebSockets server<p> 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.<p> Instances of HttpServer are thread-safe.<p>
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the server.
|
void |
close(Handler<AsyncResult<Void>> completionHandler)
Close the server.
|
HttpServer |
listen() |
HttpServer |
listen(Handler<AsyncResult<HttpServer>> listenHandler) |
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.
|
metricBaseName, metrics
HttpServerRequestStream requestStream()
Return the request stream for the server. As HTTP requests are received by the server,
instances of HttpServerRequest
will be created and passed to this stream ReadStream.handler(io.vertx.core.Handler)
.
HttpServer requestHandler(Handler<HttpServerRequest> 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.
Handler<HttpServerRequest> requestHandler()
ServerWebSocketStream websocketStream()
Return the websocket stream for the server. If a websocket connect handshake is successful a
new ServerWebSocket
instance will be created and passed to this stream ReadStream.handler(io.vertx.core.Handler)
.
HttpServer websocketHandler(Handler<ServerWebSocket> handler)
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.
Handler<ServerWebSocket> websocketHandler()
HttpServer listen()
HttpServer listen(Handler<AsyncResult<HttpServer>> listenHandler)
void close()
Close the server. Any open HTTP connections will be closed.
void close(Handler<AsyncResult<Void>> completionHandler)
Close the server. Any open HTTP connections will be closed. The completionHandler
will be called when the close
is complete.
Copyright © 2014. All Rights Reserved.