Sha256: c26c875312f396f4c16e64c48f6de881c117b83945f434ecd2bae5a8e4978895

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

require 'net/http/server/daemon'

require 'net/protocol'

module Net
  class HTTP < Protocol
    module Server
      #
      # Starts the HTTP Server.
      #
      # @param [Hash] options
      #   Options for the server.
      #
      # @option options [String] :host (DEFAULT_HOST)
      #   The host to run on.
      #
      # @option options [String] :port (DEFAULT_PORT)
      #   The port to listen on.
      #
      # @option options [Integer] :max_connections (MAX_CONNECTIONS)
      #   The maximum number of simultaneous connections.
      #
      # @option options [Boolean] :background (false)
      #   Specifies whether to run the server in the background or
      #   foreground.
      #
      # @option options [#call] :handler
      #   The HTTP Request Handler object.
      #
      # @yield [request, socket]
      #   If a block is given, it will be used to process HTTP Requests.
      #
      # @yieldparam [Hash{Symbol => String,Array,Hash}] request
      #   The HTTP Request.
      #
      # @yieldparam [TCPSocket] socket
      #   The TCP socket of the client.
      #
      def Server.run(options={},&block)
        daemon = Daemon.new(options,&block)

        daemon.start
        daemon.join unless options[:background]
        return daemon
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
net-http-server-0.2.2 lib/net/http/server/server.rb
net-http-server-0.2.1 lib/net/http/server/server.rb
net-http-server-0.2.0 lib/net/http/server/server.rb
net-http-server-0.1.0 lib/net/http/server/server.rb