Class: MemoryTracker::Middleware
- Inherits:
-
Object
- Object
- MemoryTracker::Middleware
- Defined in:
- lib/memory_tracker/middleware.rb
Overview
Middleware responsability is to initialize and close request objects object at start and end of HTTP query.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
- #memory_tracker ⇒ Object
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
5 6 7 |
# File 'lib/memory_tracker/middleware.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/memory_tracker/middleware.rb', line 13 def call(env) memory_tracker.start_request(Env.new(env)) status, headers, body = @app.call(env) ensure memory_tracker.end_request end |
#memory_tracker ⇒ Object
9 10 11 |
# File 'lib/memory_tracker/middleware.rb', line 9 def memory_tracker MemoryTracker.instance end |