# Class: HttpServer

## vertx-js/http_server~ HttpServer

#### new HttpServer()

An HTTP and WebSockets server.

Source:
  - vertx-js/http_server.js, line 35

### 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:
  - vertx-js/http_server.js, line 224

##### 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:
  - vertx-js/http_server.js, line 201

#### connectionHandler(handler) → {HttpServer}

Set a connection handler for the server.

##### Parameters:

Name | Type | Description
--- | --- | ---
`handler` | function |

Source:
  - vertx-js/http_server.js, line 98

##### 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:
  - vertx-js/http_server.js, line 48

##### 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:
  - vertx-js/http_server.js, line 154

##### 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:
  - vertx-js/http_server.js, line 81

##### 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:
  - vertx-js/http_server.js, line 63

##### 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:
  - vertx-js/http_server.js, line 134

##### 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:
  - vertx-js/http_server.js, line 116

##### Returns:

the websocket stream

Type
  ServerWebSocketStream