Package: io.vertx.groovy.core.http

## [Groovy] Class HttpServer

- io.vertx.groovy.core.http.HttpServer

- All Implemented Interfaces and Traits:
    Measured

      @groovy.transform.CompileStatic
      class HttpServer
      extends java.lang.Object

  An HTTP and WebSockets server.

  You receive HTTP requests by providing a HttpServer.requestHandler. As requests arrive on the server the handler will be called with the requests.

  You receive WebSockets by providing a HttpServer.websocketHandler. As WebSocket connections arrive on the server, the WebSocket is passed to the handler.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `HttpServer (java.lang.Object delegate)`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `int` | `actualPort()` The actual port the server is listening on.
    `void` | `close()` Close the server.
    `void` | `close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> completionHandler)` Like HttpServer.close but supplying a handler that will be called when the server is actually closed (or has failed).
    `HttpServer` | `connectionHandler(io.vertx.core.Handler<HttpConnection> handler)` Set a connection handler for the server.
    `java.lang.Object` | `getDelegate()`
    `boolean` | `isMetricsEnabled()` Whether the metrics are enabled for this measured object
    `HttpServer` | `listen()` Tell the server to start listening.
    `HttpServer` | `listen(int port, java.lang.String host)` Tell the server to start listening.
    `HttpServer` | `listen(int port, java.lang.String host, io.vertx.core.Handler<io.vertx.core.AsyncResult<HttpServer>> listenHandler)` Like HttpServer.listen but supplying a handler that will be called when the server is actually listening (or has failed).
    `HttpServer` | `listen(int port)` Like HttpServer.listen but the server will listen on host "0.0.0.0" and port specified here ignoring any value in the | `HttpServer` | `listen(int port, io.vertx.core.Handler<io.vertx.core.AsyncResult<HttpServer>> listenHandler)` Like HttpServer.listen but supplying a handler that will be called when the server is actually listening (or has failed).
    `HttpServer` | `listen(io.vertx.core.Handler<io.vertx.core.AsyncResult<HttpServer>> listenHandler)` Like HttpServer.listen but supplying a handler that will be called when the server is actually listening (or has failed).
    `HttpServer` | `requestHandler(io.vertx.core.Handler<HttpServerRequest> handler)` Set the request handler for the server to `requestHandler`.
    `HttpServerRequestStream` | `requestStream()` Return the request stream for the server.
    `HttpServer` | `websocketHandler(io.vertx.core.Handler<ServerWebSocket> handler)` Set the websocket handler for the server to `wsHandler`.
    `ServerWebSocketStream` | `websocketStream()` Return the websocket stream for the server.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### HttpServer(java.lang.Object delegate)

  - ### Method Detail

    - #### int actualPort()

      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

      Returns:
        the actual port the server is listening on.

    - #### void close()

      Close the server. Any open HTTP connections will be closed.

      The close happens asynchronously and the server may not be closed until some time after the call has returned.

    - #### void close(io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> completionHandler)

      Like HttpServer.close but supplying a handler that will be called when the server is actually closed (or has failed).

      Parameters:
        `completionHandler` - the handler

    - #### HttpServer connectionHandler(io.vertx.core.Handler<HttpConnection> handler)

      Set a connection handler for the server.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        handler

    - #### java.lang.Object getDelegate()

    - #### boolean isMetricsEnabled()

      Whether the metrics are enabled for this measured object

      Returns:
        true if the metrics are enabled

    - #### HttpServer listen()

      Tell the server to start listening. The server will listen on the port and host specified in the 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.

      Returns:
        a reference to this, so the API can be used fluently

    - #### HttpServer listen(int port, java.lang.String host)

      Tell the server to start listening. The server will listen on the port and host specified here, ignoring any value set in the 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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `port` - the port to listen on
        `host` - the host to listen on

    - #### HttpServer listen(int port, java.lang.String host, io.vertx.core.Handler<io.vertx.core.AsyncResult<HttpServer>> listenHandler)

      Like HttpServer.listen but supplying a handler that will be called when the server is actually listening (or has failed).

      Returns:
      Parameters:
        `port` - the port to listen on
        `host` - the host to listen on
        `listenHandler` - the listen handler

    - #### HttpServer listen(int port)

      Like HttpServer.listen 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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        `port` - the port to listen on

    - #### HttpServer listen(int port, io.vertx.core.Handler<io.vertx.core.AsyncResult<HttpServer>> listenHandler)

      Like HttpServer.listen but supplying a handler that will be called when the server is actually listening (or has failed).

      Returns:
      Parameters:
        `port` - the port to listen on
        `listenHandler` - the listen handler

    - #### HttpServer listen(io.vertx.core.Handler<io.vertx.core.AsyncResult<HttpServer>> listenHandler)

      Like HttpServer.listen but supplying a handler that will be called when the server is actually listening (or has failed).

      Returns:
      Parameters:
        `listenHandler` - the listen handler

    - #### HttpServer requestHandler(io.vertx.core.Handler<HttpServerRequest> handler)

      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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        handler

    - #### HttpServerRequestStream requestStream()

      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 .

      Returns:
        the request stream

    - #### HttpServer websocketHandler(io.vertx.core.Handler<ServerWebSocket> handler)

      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.

      Returns:
        a reference to this, so the API can be used fluently
      Parameters:
        handler

    - #### ServerWebSocketStream websocketStream()

      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 .

      Returns:
        the websocket stream