Mercurial > maze-src
annotate net/http/server/server.rb @ 0:1eef88068f9f tip
initial commit of maze game source
| author | ferencd |
|---|---|
| date | Sun, 15 Sep 2019 11:46:47 +0200 |
| parents | |
| children |
| rev | line source |
|---|---|
| ferencd@0 | 1 require 'net/http/server/daemon' |
| ferencd@0 | 2 |
| ferencd@0 | 3 require 'net/protocol' |
| ferencd@0 | 4 |
| ferencd@0 | 5 module Net |
| ferencd@0 | 6 class HTTP < Protocol |
| ferencd@0 | 7 module Server |
| ferencd@0 | 8 # |
| ferencd@0 | 9 # Starts the HTTP Server. |
| ferencd@0 | 10 # |
| ferencd@0 | 11 # @param [Hash] options |
| ferencd@0 | 12 # Options for the server. |
| ferencd@0 | 13 # |
| ferencd@0 | 14 # @option options [String] :host (DEFAULT_HOST) |
| ferencd@0 | 15 # The host to run on. |
| ferencd@0 | 16 # |
| ferencd@0 | 17 # @option options [String] :port (DEFAULT_PORT) |
| ferencd@0 | 18 # The port to listen on. |
| ferencd@0 | 19 # |
| ferencd@0 | 20 # @option options [Integer] :max_connections (MAX_CONNECTIONS) |
| ferencd@0 | 21 # The maximum number of simultaneous connections. |
| ferencd@0 | 22 # |
| ferencd@0 | 23 # @option options [Boolean] :background (false) |
| ferencd@0 | 24 # Specifies whether to run the server in the background or |
| ferencd@0 | 25 # foreground. |
| ferencd@0 | 26 # |
| ferencd@0 | 27 # @option options [#call] :handler |
| ferencd@0 | 28 # The HTTP Request Handler object. |
| ferencd@0 | 29 # |
| ferencd@0 | 30 # @yield [request, socket] |
| ferencd@0 | 31 # If a block is given, it will be used to process HTTP Requests. |
| ferencd@0 | 32 # |
| ferencd@0 | 33 # @yieldparam [Hash{Symbol => String,Array,Hash}] request |
| ferencd@0 | 34 # The HTTP Request. |
| ferencd@0 | 35 # |
| ferencd@0 | 36 # @yieldparam [TCPSocket] socket |
| ferencd@0 | 37 # The TCP socket of the client. |
| ferencd@0 | 38 # |
| ferencd@0 | 39 def Server.run(options={},&block) |
| ferencd@0 | 40 daemon = Daemon.new(options,&block) |
| ferencd@0 | 41 |
| ferencd@0 | 42 daemon.start |
| ferencd@0 | 43 daemon.join unless options[:background] |
| ferencd@0 | 44 return daemon |
| ferencd@0 | 45 end |
| ferencd@0 | 46 |
| ferencd@0 | 47 end |
| ferencd@0 | 48 end |
| ferencd@0 | 49 end |
