Class: RequestReplay::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/request-replay/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, host, options = {}) ⇒ Middleware

Returns a new instance of Middleware.



5
6
7
# File 'lib/request-replay/middleware.rb', line 5

def initialize app, host, options={}
  @app, @host, @options = app, host, options
end

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
# File 'lib/request-replay/middleware.rb', line 9

def call env
  # We don't want to read the socket in a thread, so create it in main
  # thread, and send the data in a thread as we don't care the responses
  Thread.new(RequestReplay.new(env, @host, @options), &:start)
  @app.call(env)
end