Class: Wunderbar::RackApp

Inherits:
Object
  • Object
show all
Defined in:
lib/wunderbar/rack.rb

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Object

entry point for Rack



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/wunderbar/rack.rb', line 7

def call(env)
  @_env = env
  @_request = Rack::Request.new(env)
  @_response = Rack::Response.new
  Wunderbar.logger = @_request.logger
  if Wunderbar.safe? and $SAFE==0
    Proc.new { $SAFE=1; Wunderbar::CGI.call(self) }.call
  else
    Wunderbar::CGI.call(self)
  end
  @_response.finish
end

#envObject



31
32
33
# File 'lib/wunderbar/rack.rb', line 31

def env
  @_env
end

#out(headers, &block) ⇒ Object

redirect the output produced



21
22
23
24
25
26
27
28
29
# File 'lib/wunderbar/rack.rb', line 21

def out(headers,&block)
  status = headers.delete('status')
  @_response.status = status if status

  headers = Wunderbar::CGI.headers(headers)
  headers.each {|key, value| @_response[key] = value}

  @_response.write block.call unless @_request.head?
end

#paramsObject



35
36
37
# File 'lib/wunderbar/rack.rb', line 35

def params
  @_request.params
end

#requestObject



39
40
41
# File 'lib/wunderbar/rack.rb', line 39

def request
  @_request
end

#responseObject



43
44
45
# File 'lib/wunderbar/rack.rb', line 43

def response
  @_response
end