Methods
actualPort() → {number}
The actual port the server is listening on. This is useful if you bound the server specifying 0 as port number
signifying an ephemeral port
- Source:
Returns:
the actual port the server is listening on.
- Type
- number
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:
connectionHandler(handler) → {HttpServer}
Set a connection handler for the server.
Parameters:
Name | Type | Description |
---|---|---|
handler |
function |
- Source:
Returns:
a reference to this, so the API can be used fluently
- Type
- HttpServer
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 .
- 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 .
- Source:
Returns:
the websocket stream
- Type
- ServerWebSocketStream