Class: GCStats::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/gc_stats/middleware.rb

Overview

Rack middleware that clears out GC::Profiler’s data on each request.

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



6
7
8
# File 'lib/gc_stats/middleware.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
# File 'lib/gc_stats/middleware.rb', line 10

def call(env)
  # clear out the profiler's data
  GC::Profiler.clear

  # pass the call onto the next link in the chain
  status, headers, response = @app.call(env)

  # pass the results back
  [status, headers, response]
end