Class: Hookout::RackAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/hookout/rack_adapter.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ RackAdapter

Returns a new instance of RackAdapter.



5
6
7
# File 'lib/hookout/rack_adapter.rb', line 5

def initialize(app)
  @app = app
end

Instance Method Details

#handle_request(request) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hookout/rack_adapter.rb', line 9

def handle_request(request)
  thin_request = Thin::Request.new
  thin_request.parse request.body

  status,headers,body = @app.call(thin_request.env)

  thin_response = Thin::Response.new
  thin_response.status = status
  thin_response.headers = headers
  thin_response.body = body

  thin_response.each do |chunk|
    request.write(chunk)
  end
end