Sha256: 7663691754ce4658f10aca78477bb946e8fb14301e5fe6670ae6adb15538abe9

Contents?: true

Size: 1 KB

Versions: 68

Compression:

Stored size: 1 KB

Contents

require 'wunderbar'
require 'rack'

module Wunderbar
  class RackApp
    # entry point for Rack
    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

    # redirect the output produced
    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

    def env
      @_env
    end

    def params
      @_request.params
    end

    def request
      @_request
    end

    def response
      @_response
    end
  end
end

class Rack::Builder
  include Wunderbar::API

  def _app
    Wunderbar::RackApp.new
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
wunderbar-1.3.0 lib/wunderbar/rack.rb
wunderbar-1.2.10 lib/wunderbar/rack.rb
wunderbar-1.2.9 lib/wunderbar/rack.rb
wunderbar-1.2.8 lib/wunderbar/rack.rb
wunderbar-1.2.7 lib/wunderbar/rack.rb
wunderbar-1.2.6 lib/wunderbar/rack.rb
wunderbar-1.2.5 lib/wunderbar/rack.rb
wunderbar-1.2.4 lib/wunderbar/rack.rb
wunderbar-1.2.3 lib/wunderbar/rack.rb
wunderbar-1.2.2 lib/wunderbar/rack.rb
wunderbar-1.2.1 lib/wunderbar/rack.rb
wunderbar-1.2.0 lib/wunderbar/rack.rb
wunderbar-1.1.2 lib/wunderbar/rack.rb
wunderbar-1.1.1 lib/wunderbar/rack.rb
wunderbar-1.1.0 lib/wunderbar/rack.rb
wunderbar-1.0.28 lib/wunderbar/rack.rb
wunderbar-1.0.27 lib/wunderbar/rack.rb
wunderbar-1.0.26 lib/wunderbar/rack.rb
wunderbar-1.0.25 lib/wunderbar/rack.rb
wunderbar-1.0.24 lib/wunderbar/rack.rb