new HttpServer()
An HTTP and WebSockets server.
- Source:
Methods
-
close(completionHandler)
-
Like HttpServer#close but supplying a handler that will be called when the server is actually closed (or has failed).
Parameters:
Name Type Description completionHandler
function the handler - Source:
-
isMetricsEnabled() → {boolean}
-
Whether the metrics are enabled for this measured object
- Source:
Returns:
true if the metrics are enabled- Type
- boolean
-
listen(port, host, listenHandler) → {HttpServer}
-
Like HttpServer#listen but supplying a handler that will be called when the server is actually listening (or has failed).
Parameters:
Name Type Description port
number the port to listen on host
string the host to listen on listenHandler
function the listen handler - Source:
Returns:
- Type
- HttpServer
-
requestHandler(handler) → {HttpServer}
-
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.Parameters:
Name Type Description handler
function - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- HttpServer
-
requestStream() → {HttpServerRequestStream}
-
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 ReadStream#handler.
- Source:
Returns:
the request stream- Type
- HttpServerRequestStream
-
websocketHandler(handler) → {HttpServer}
-
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.Parameters:
Name Type Description handler
function - Source:
Returns:
a reference to this, so the API can be used fluently- Type
- HttpServer
-
websocketStream() → {ServerWebSocketStream}
-
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 ReadStream#handler.
- Source:
Returns:
the websocket stream- Type
- ServerWebSocketStream