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