Package ej.hoka.http

Class HttpServer.HttpServerBuilder

    • Method Detail

      • port

        public HttpServer.HttpServerBuilder port​(int port)
        Set the server port number.
        Parameters:
        port - server port. use 0 set setup a random available port.
        Returns:
        HttpServer.HttpServerBuilder to continue setting up the server parameters
        Throws:
        java.lang.IllegalArgumentException - if port is < 0
      • simultaneousConnections

        public HttpServer.HttpServerBuilder simultaneousConnections​(int simultaneousConnections)
        Set the max simultaneous connections.
        Parameters:
        simultaneousConnections - max simultaneous connections that can be handled by the server.
        Returns:
        HttpServer.HttpServerBuilder to continue setting up the server parameters
        Throws:
        java.lang.IllegalArgumentException - - if simultaneousConnections is <= 0;
      • workerCount

        public HttpServer.HttpServerBuilder workerCount​(int workerCount)
        Set threads count that handles incoming request.
        Parameters:
        workerCount - number of threads to handle incoming requests
        Returns:
        HttpServer.HttpServerBuilder to continue setting up the server parameters
        Throws:
        java.lang.IllegalArgumentException - - if workerCount is <= 0;
      • apiBase

        public HttpServer.HttpServerBuilder apiBase​(@Nullable
                                                    java.lang.String apiBase)
        Add a path common base that will be appended to all routes mapped without starting with a forward slash '/'. This is useful when dealing with rest API to set the rest api URI base once. The base should start with a '/' and also ends with a '/'.
        Parameters:
        apiBase - the api base path
        Returns:
        HttpServer.HttpServerBuilder to continue setting up the server parameters
        Throws:
        java.lang.IllegalArgumentException - if apiBase is null or empty
      • secure

        public HttpServer.HttpServerBuilder secure​(@Nullable
                                                   javax.net.ServerSocketFactory ssf)
        Set Server Socket Factory. this used to set ssl
        Parameters:
        ssf - Server socket factory to setup HTTPS
        Returns:
        HttpServer.HttpServerBuilder to continue setting up the server parameters
        Throws:
        java.lang.IllegalArgumentException - if ServerSocketFactory parameter is null
      • connectionTimeout

        public HttpServer.HttpServerBuilder connectionTimeout​(int connectionTimeout)
        By default, server is configured to keep connection open during one minute if possible. A timeout of zero is interpreted as an infinite timeout.
        Parameters:
        connectionTimeout - the timeout duration.
        Returns:
        HttpServer.HttpServerBuilder to continue setting up the server parameters
        Throws:
        java.lang.IllegalArgumentException - if connectionTimeout < 0
      • withTrailingSlashSupport

        public HttpServer.HttpServerBuilder withTrailingSlashSupport()
        Activate trailing slash matching support in URI. When used URI '/hello' and '/hello/' will point to different request handler otherwise URI '/hello' and '/hello/' are the same
        Returns:
        HttpServer.HttpServerBuilder to continue setting up the server parameters
      • build

        public HttpServer build()
        Builds and returns an instance of HttpServer with the configured parameters.
        Returns:
        an instance of HttpServer with the configured parameters.