public class HttpServer extends Object implements Measured
You receive HTTP requests by providing a requestHandler(io.vertx.core.Handler<io.vertx.rxjava.core.http.HttpServerRequest>)
. As requests arrive on the server the handler
will be called with the requests.
You receive WebSockets by providing a websocketHandler(io.vertx.core.Handler<io.vertx.rxjava.core.http.ServerWebSocket>)
. As WebSocket connections arrive on the server, the
WebSocket is passed to the handler.
original
non RX-ified interface using Vert.x codegen.Constructor and Description |
---|
HttpServer(HttpServer delegate) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the server.
|
void |
close(Handler<AsyncResult<Void>> completionHandler)
Like
HttpServer but supplying a handler that will be called when the server is actually closed (or has failed). |
rx.Observable<Void> |
closeObservable()
Like
HttpServer but supplying a handler that will be called when the server is actually closed (or has failed). |
Object |
getDelegate() |
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 but supplying a handler that will be called when the server is actually listening (or has failed). |
HttpServer |
listen(int port)
Like
HttpServer 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
listen() 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
listen() but supplying a handler that will be called when the server is actually
listening (or has failed). |
rx.Observable<HttpServer> |
listenObservable()
Like
listen() but supplying a handler that will be called when the server is actually listening (or has failed). |
rx.Observable<HttpServer> |
listenObservable(int port)
Like
listen() but supplying a handler that will be called when the server is actually listening (or has failed). |
rx.Observable<HttpServer> |
listenObservable(int port,
String host)
Like
listen() but supplying a handler that will be called when the server is actually
listening (or has failed). |
static HttpServer |
newInstance(HttpServer arg) |
HttpServer |
requestHandler(Handler<HttpServerRequest> handler)
Set the request handler for the server to
requestHandler . |
HttpServerRequestStream |
requestStream()
Return the request stream for the server.
|
HttpServer |
websocketHandler(Handler<ServerWebSocket> handler)
Set the websocket handler for the server to
wsHandler . |
ServerWebSocketStream |
websocketStream()
Return the websocket stream for the server.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
newInstance
public HttpServer(HttpServer delegate)
public Object getDelegate()
getDelegate
in interface Measured
public boolean isMetricsEnabled()
isMetricsEnabled
in interface Measured
public HttpServerRequestStream requestStream()
HttpServerRequest
will be created and passed to the stream ReadStream
.public HttpServer requestHandler(Handler<HttpServerRequest> handler)
requestHandler
. As HTTP requests are received by the server,
instances of HttpServerRequest
will be created and passed to this handler.handler
- public ServerWebSocketStream websocketStream()
ServerWebSocket
instance will be created and passed to the stream ReadStream.handler(io.vertx.core.Handler<T>)
.public HttpServer websocketHandler(Handler<ServerWebSocket> handler)
wsHandler
. If a websocket connect handshake is successful a
new ServerWebSocket
instance will be created and passed to the handler.handler
- public HttpServer listen()
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.
public HttpServer listen(int port, String host)
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 onpublic HttpServer listen(int port, String host, Handler<AsyncResult<HttpServer>> listenHandler)
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 handlerpublic rx.Observable<HttpServer> listenObservable(int port, String host)
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 onpublic HttpServer listen(int port)
HttpServer
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 onpublic HttpServer listen(int port, Handler<AsyncResult<HttpServer>> listenHandler)
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 handlerpublic rx.Observable<HttpServer> listenObservable(int port)
listen()
but supplying a handler that will be called when the server is actually listening (or has failed).port
- the port to listen onpublic HttpServer listen(Handler<AsyncResult<HttpServer>> listenHandler)
HttpServer
but supplying a handler that will be called when the server is actually listening (or has failed).listenHandler
- the listen handlerpublic rx.Observable<HttpServer> listenObservable()
listen()
but supplying a handler that will be called when the server is actually listening (or has failed).public void close()
The close happens asynchronously and the server may not be closed until some time after the call has returned.
public void close(Handler<AsyncResult<Void>> completionHandler)
HttpServer
but supplying a handler that will be called when the server is actually closed (or has failed).completionHandler
- the handlerpublic rx.Observable<Void> closeObservable()
HttpServer
but supplying a handler that will be called when the server is actually closed (or has failed).public static HttpServer newInstance(HttpServer arg)
Copyright © 2015. All Rights Reserved.