Class: WebSystem::RackPanel

Inherits:
Liza::Panel show all
Defined in:
lib/web_system/sub/rack/rack_panel.rb

Defined Under Namespace

Classes: NotSet

Instance Attribute Summary

Attributes inherited from Liza::Panel

#key

Instance Method Summary collapse

Methods inherited from Liza::Panel

box, #box, color, #controller, controller, division, #division, #initialize, #push, #short, #started, subsystem, #subsystem, token

Methods inherited from Liza::Unit

const_missing, division, part, system, #system, test_class

Constructor Details

This class inherits a constructor from Liza::Panel

Instance Method Details

#call(env) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/web_system/sub/rack/rack_panel.rb', line 4

def call env
  puts

  env[:server] ||= get :server
  env[:host] ||= get :host
  env[:port] ||= get :port

  self.server env[:server]
  set :host, env[:host]
  set :port, env[:port]

  log(env)

  self.server.call(self.rack_app)
end

#rack_appObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/web_system/sub/rack/rack_panel.rb', line 31

def rack_app
  return @rack_app if @rack_app

  rack_app = @rack_app = WebBox[:request]

  ENV["RACK_ENV"] = $coding ? "development" : "production"

  rack_app = WebBox[:request]
  rack_app = LastMiddleRack.new rack_app
  rack_app = FirstMiddleRack.new rack_app
  rack_app = ZeitwerkMiddleRack.new rack_app if $coding

  require "rack"

  files ||= get :files
  rack_files = Object::Rack::Files.new files
  rack_app = Object::Rack::Cascade.new [rack_files, rack_app]
  
  rack_app
end

#server(name = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/web_system/sub/rack/rack_panel.rb', line 20

def server name = nil
  if name
    @server = Liza.const(:"#{name}_server_rack")
    set :server, name
  elsif @server.nil?
    raise NotSet, "Please set your rack server on your web_box.rb file", caller 
  else
    @server
  end
end