Class HttpServer

  • All Implemented Interfaces:
    java.io.Closeable , java.lang.AutoCloseable

    
    public final class HttpServer
     implements Closeable
                        

    Server that listen to HTTP connections on a port and address and route requests to handlers.

    • Constructor Detail

      • HttpServer

        HttpServer(HttpServerPort adapter, HttpServerSettings settings, Function1<HandlerBuilder, Unit> block)
        Create a server with a builder (HandlerBuilder) to set up handlers.
        Parameters:
        adapter - The server engine.
        settings - Server settings.
        block - Handlers' setup block.
    • Method Detail

      • getPortName

         final String getPortName()

        The port name of the server.

      • started

         final Boolean started()

        Check whether the server has been started.

        Returns:

        True if the server has started, else false.

      • start

         final Unit start()

        Start the server with the adapter instance and adds a shutdown hook for stopping the server.

      • stop

         final Unit stop()

        Stop the server.