Class: Webcommand::Server::Adapters::Webrick

Inherits:
Object
  • Object
show all
Defined in:
lib/webcommand/server/adapters/webrick.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, options) ⇒ Webrick

Returns a new instance of Webrick.



5
6
7
8
9
# File 'lib/webcommand/server/adapters/webrick.rb', line 5

def initialize(server, options)
  require 'webrick'
  @server = server
  @options = options
end

Instance Method Details

#startObject



11
12
13
14
15
16
17
18
# File 'lib/webcommand/server/adapters/webrick.rb', line 11

def start
  server = WEBrick::HTTPServer.new(
    Port: @options[:port],
    BindAddress: @options[:bind])
  server.mount "/", Rack::Handler::WEBrick, server
  Signal.trap(:INT) { server.shutdown }
  server.start
end