Class: Ramaze::Adapter::WEBrick

Inherits:
Base show all
Defined in:
lib/ramaze/adapter/webrick.rb

Overview

Our WEBrick adapter acts as wrapper for the Rack::Handler::WEBrick.

Class Method Summary collapse

Methods inherited from Base

before, before_call, call, middleware_respond, respond, start, stop

Class Method Details

.run_server(host, port, options = {}) ⇒ Object

start server on given host and port, see below for possible options.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ramaze/adapter/webrick.rb', line 14

def run_server host, port, options = {}
  options = {
    :Port        => port,
    :BindAddress => host,
    :Logger      => Log,
    :AccessLog   => [
      [Log, ::WEBrick::AccessLog::COMMON_LOG_FORMAT],
      [Log, ::WEBrick::AccessLog::REFERER_LOG_FORMAT]
    ]
  }.merge(options)


  server = ::WEBrick::HTTPServer.new(options)
  server.mount("/", ::Rack::Handler::WEBrick, self)
  thread = Thread.new(server) do |adapter|
    Thread.current[:adapter] = adapter
    adapter.start
  end
end