# Class: HttpServer

## vertx-js/http_server~ HttpServer

#### new HttpServer()

  An HTTP and WebSockets server.

  Source:
    - http_server.js, line 34

### 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:
    - http_server.js, line 175

#### isMetricsEnabled() → {boolean}

  Whether the metrics are enabled for this measured object
  Source:
    - http_server.js, line 47

  ##### 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:
    - http_server.js, line 128

  ##### 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:
    - http_server.js, line 77

  ##### 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:
    - http_server.js, line 62

  ##### 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:
    - http_server.js, line 109

  ##### 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:
    - http_server.js, line 94

  ##### Returns:

  the websocket stream
  Type
    ServerWebSocketStream