Class: BitClust::Interface

Inherits:
Object show all
Defined in:
lib/bitclust/interface.rb

Overview

Web server interface for BitClust server

Defined Under Namespace

Classes: CGI, FCGI, WEBrickServlet

Instance Method Summary collapse

Constructor Details

#initialize(webrick_conf = {}) ⇒ Interface

Returns a new instance of Interface.


22
23
24
25
# File 'lib/bitclust/interface.rb', line 22

def initialize(webrick_conf = {})
  @webrick_conf = webrick_conf
  @handler = ($bitclust_context_cache ||= yield)
end

Instance Method Details

#call(env) ⇒ Object

for rack


42
43
44
# File 'lib/bitclust/interface.rb', line 42

def call(env)
  @handler.handle(Rack::Request.new(env)).rack_finish
end

#get_instance(server) ⇒ Object

for WEBrick servlet


28
29
30
# File 'lib/bitclust/interface.rb', line 28

def get_instance(server)
  WEBrickServlet.new(server, @handler)
end

#mainObject


32
33
34
35
36
37
38
39
# File 'lib/bitclust/interface.rb', line 32

def main
  if fastcgi?
    FCGI.new(@webrick_conf).main(@handler)
  else
    # CGI, mod_ruby
    CGI.new(@webrick_conf).main(@handler)
  end
end