Class: IRWebmachine::TracedRequest
- Inherits:
-
Object
- Object
- IRWebmachine::TracedRequest
- Defined in:
- lib/irwebmachine/traced_request.rb
Instance Method Summary collapse
-
#initialize(app) ⇒ IRWebmachine::TracedRequest
constructor
Returns an instance of IRWebmachine::TracedRequest.
-
#stack ⇒ IRWebmachine::Stack
Returns an instance of Webmachine::Stack.
- #to_a ⇒ Array
- #trace(*args) ⇒ Object
- #trace!(type, path, params = {}, headers = {}, body = "") ⇒ Object
Constructor Details
#initialize(app) ⇒ IRWebmachine::TracedRequest
Returns an instance of IRWebmachine::TracedRequest.
9 10 11 12 13 14 |
# File 'lib/irwebmachine/traced_request.rb', line 9 def initialize(app) @app = app @req = nil @res = nil @stack = IRWebmachine::Stack.new end |
Instance Method Details
#stack ⇒ IRWebmachine::Stack
Returns an instance of Webmachine::Stack.
20 21 22 |
# File 'lib/irwebmachine/traced_request.rb', line 20 def stack @stack end |
#to_a ⇒ Array
51 52 53 |
# File 'lib/irwebmachine/traced_request.rb', line 51 def to_a [@req.method, @req.uri.path, @req.query, @req.headers, @req.body] end |
#trace(*args) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/irwebmachine/traced_request.rb', line 24 def trace(*args) trace!(*args) while frame = @stack.tracer.continue @stack << frame end @res end |
#trace!(type, path, params = {}, headers = {}, body = "") ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/irwebmachine/traced_request.rb', line 32 def trace!(type, path, params = {}, headers = {}, body = "") uri = URI::HTTP.build(host: "localhost", path: path) uri.query_params.merge!(params) @req = Webmachine::Request.new type.upcase, uri, headers, body @res = Webmachine::Response.new @stack.tracer.trace do @app.dispatcher.dispatch @req, @res end @res end |