Class HttpServer

    • Constructor Detail

      • HttpServer

        public HttpServer​(io.vertx.core.http.HttpServer delegate)
      • HttpServer

        public HttpServer​(Object delegate)
    • Method Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getDelegate

        public io.vertx.core.http.HttpServer getDelegate()
        Specified by:
        getDelegate in interface Measured
      • isMetricsEnabled

        public boolean isMetricsEnabled()
        Whether the metrics are enabled for this measured object
        Specified by:
        isMetricsEnabled in interface Measured
        Returns:
        true if metrics are enabled
      • requestHandler

        public 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.
        Parameters:
        handler -
        Returns:
        a reference to this, so the API can be used fluently
      • invalidRequestHandler

        public HttpServer invalidRequestHandler​(io.vertx.core.Handler<HttpServerRequest> handler)
        Set a handler for handling invalid requests. When an invalid request is received by the server this handler will be called with the request. The handler can send any HTTP response, when the response ends, the server shall close the connection. io.vertx.rxjava3.core.http.HttpServerRequest#decoderResult can be used to obtain the Netty decoder result and the failure cause reported by the decoder.

        Currently this handler is only used for HTTP/1.x requests.

        When no specific handler is set, the HttpServerRequest is used.

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

        public HttpServer connectionHandler​(io.vertx.core.Handler<HttpConnection> handler)
        Set a connection handler for the server.
        The handler will always be called on the event-loop thread.
        Parameters:
        handler -
        Returns:
        a reference to this, so the API can be used fluently
      • exceptionHandler

        public HttpServer exceptionHandler​(io.vertx.core.Handler<Throwable> handler)
        Set an exception handler called for socket errors happening before the HTTP connection is established, e.g during the TLS handshake.
        Parameters:
        handler - the handler to set
        Returns:
        a reference to this, so the API can be used fluently
      • webSocketHandler

        public 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.
        Parameters:
        handler -
        Returns:
        a reference to this, so the API can be used fluently
      • updateSSLOptions

        public io.reactivex.rxjava3.core.Single<Boolean> updateSSLOptions​(io.vertx.core.net.SSLOptions options)
        Like updateSSLOptions(io.vertx.core.net.SSLOptions) but supplying a handler that will be called when the update happened (or has failed).
        Parameters:
        options - the new SSL options
        Returns:
      • rxUpdateSSLOptions

        public io.reactivex.rxjava3.core.Single<Boolean> rxUpdateSSLOptions​(io.vertx.core.net.SSLOptions options)
        Like updateSSLOptions(io.vertx.core.net.SSLOptions) but supplying a handler that will be called when the update happened (or has failed).
        Parameters:
        options - the new SSL options
        Returns:
      • updateSSLOptions

        public io.reactivex.rxjava3.core.Single<Boolean> updateSSLOptions​(io.vertx.core.net.SSLOptions options,
                                                                          boolean force)
        Like updateSSLOptions(io.vertx.core.net.SSLOptions) but supplying a handler that will be called when the update happened (or has failed).
        Parameters:
        options - the new SSL options
        force - force the update when options are equals
        Returns:
      • rxUpdateSSLOptions

        public io.reactivex.rxjava3.core.Single<Boolean> rxUpdateSSLOptions​(io.vertx.core.net.SSLOptions options,
                                                                            boolean force)
        Like updateSSLOptions(io.vertx.core.net.SSLOptions) but supplying a handler that will be called when the update happened (or has failed).
        Parameters:
        options - the new SSL options
        force - force the update when options are equals
        Returns:
      • updateTrafficShapingOptions

        public void updateTrafficShapingOptions​(io.vertx.core.net.TrafficShapingOptions options)
        Update traffic shaping options options, the update happens if valid values are passed for traffic shaping options. This update happens synchronously and at best effort for rate update to take effect immediately.
        Parameters:
        options - the new traffic shaping options
      • listen

        public io.reactivex.rxjava3.core.Single<HttpServer> listen​(int port,
                                                                   String host)
        Like listen(int, java.lang.String) but supplying a handler that will be called when the server is actually listening (or has failed).
        Parameters:
        port - the port to listen on
        host - the host to listen on
        Returns:
      • rxListen

        public io.reactivex.rxjava3.core.Single<HttpServer> rxListen​(int port,
                                                                     String host)
        Like listen(int, java.lang.String) but supplying a handler that will be called when the server is actually listening (or has failed).
        Parameters:
        port - the port to listen on
        host - the host to listen on
        Returns:
      • listen

        public io.reactivex.rxjava3.core.Single<HttpServer> listen​(SocketAddress address)
        Tell the server to start listening on the given address supplying a handler that will be called when the server is actually listening (or has failed).
        Parameters:
        address - the address to listen on
        Returns:
      • rxListen

        public io.reactivex.rxjava3.core.Single<HttpServer> rxListen​(SocketAddress address)
        Tell the server to start listening on the given address supplying a handler that will be called when the server is actually listening (or has failed).
        Parameters:
        address - the address to listen on
        Returns:
      • listen

        public io.reactivex.rxjava3.core.Single<HttpServer> listen​(int port)
        Like listen(int, java.lang.String) but supplying a handler that will be called when the server is actually listening (or has failed).
        Parameters:
        port - the port to listen on
        Returns:
      • rxListen

        public io.reactivex.rxjava3.core.Single<HttpServer> rxListen​(int port)
        Like listen(int, java.lang.String) but supplying a handler that will be called when the server is actually listening (or has failed).
        Parameters:
        port - the port to listen on
        Returns:
      • listen

        public io.reactivex.rxjava3.core.Single<HttpServer> listen()
        Like listen(int, java.lang.String) but supplying a handler that will be called when the server is actually listening (or has failed).
        Returns:
      • rxListen

        public io.reactivex.rxjava3.core.Single<HttpServer> rxListen()
        Like listen(int, java.lang.String) but supplying a handler that will be called when the server is actually listening (or has failed).
        Returns:
      • close

        public io.reactivex.rxjava3.core.Completable close()
        Like close() but supplying a handler that will be called when the server is actually closed (or has failed).
        Returns:
      • rxClose

        public io.reactivex.rxjava3.core.Completable rxClose()
        Like close() but supplying a handler that will be called when the server is actually closed (or has failed).
        Returns:
      • actualPort

        public 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.
      • newInstance

        public static HttpServer newInstance​(io.vertx.core.http.HttpServer arg)