Class: WireTap::Listener
- Inherits:
-
Object
- Object
- WireTap::Listener
- Defined in:
- lib/wire_tap/listener.rb
Instance Attribute Summary collapse
-
#transactions ⇒ Object
readonly
Returns the value of attribute transactions.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Listener
constructor
A new instance of Listener.
- #parse_request(request) ⇒ Object
- #parse_response(response) ⇒ Object
- #parse_transaction(env, response) ⇒ Object
Constructor Details
#initialize(app) ⇒ Listener
Returns a new instance of Listener.
6 7 8 9 |
# File 'lib/wire_tap/listener.rb', line 6 def initialize app @app = app @transactions = [] end |
Instance Attribute Details
#transactions ⇒ Object (readonly)
Returns the value of attribute transactions.
5 6 7 |
# File 'lib/wire_tap/listener.rb', line 5 def transactions @transactions end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 |
# File 'lib/wire_tap/listener.rb', line 10 def call(env) response = @app.call(env) @transactions << parse_transaction(env, response) response end |
#parse_request(request) ⇒ Object
15 16 17 |
# File 'lib/wire_tap/listener.rb', line 15 def parse_request(request) RequestParser.parse(request) end |
#parse_response(response) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/wire_tap/listener.rb', line 18 def parse_response(response) status,headers,body = response { :status => status, :content_type => headers["Content-Type"], :body => body } end |
#parse_transaction(env, response) ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/wire_tap/listener.rb', line 26 def parse_transaction(env, response) { :method=>env["REQUEST_METHOD"], :path=>env["PATH_INFO"], :request => parse_request(env["rack.input"].read) }.merge(parse_response(response)) end |