Class: SnowmanIO::WebServer
- Inherits:
-
Reel::Server::HTTP
- Object
- Reel::Server::HTTP
- SnowmanIO::WebServer
- Defined in:
- lib/snowman-io/web_server.rb
Defined Under Namespace
Classes: ConnectionHandler
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
-
#initialize(app, options) ⇒ WebServer
constructor
A new instance of WebServer.
- #on_connection(connection) ⇒ Object
Constructor Details
#initialize(app, options) ⇒ WebServer
Returns a new instance of WebServer.
89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/snowman-io/web_server.rb', line 89 def initialize(app, ) raise ArgumentError, "no host given" unless [:host] raise ArgumentError, "no port given" unless [:port] SnowmanIO.logger.info "Snowman WebServer started on http://#{[:host]}:#{[:port]}" # TODO: not sure, maybe should log without verbose option too app = Rack::CommonLogger.new(app, STDOUT) if [:verbose] super([:host], [:port], &method(:on_connection)) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
6 7 8 |
# File 'lib/snowman-io/web_server.rb', line 6 def app @app end |
Instance Method Details
#on_connection(connection) ⇒ Object
102 103 104 105 |
# File 'lib/snowman-io/web_server.rb', line 102 def on_connection(connection) # connection.detach ConnectionHandler.new(connection, @app) end |