Class: Leafy::Rack::ThreadDump

Inherits:
Object
  • Object
show all
Defined in:
lib/leafy/rack/thread_dump.rb

Constant Summary collapse

WRITER =
ThreadDumpWriter.new

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, path = '/threads') ⇒ ThreadDump

Returns a new instance of ThreadDump.



42
43
44
45
# File 'lib/leafy/rack/thread_dump.rb', line 42

def initialize(app, path = '/threads')
  @app = app
  @path = path
end

Class Method Details

.responseObject



32
33
34
35
36
37
38
39
40
# File 'lib/leafy/rack/thread_dump.rb', line 32

def self.response
  dump = WRITER.to_text
  [  
   200, 
   { 'Content-Type' => 'text/plain',
     'Cache-Control' => 'must-revalidate,no-cache,no-store' }, 
   [ dump ? dump : 'Sorry your runtime environment does not allow to dump threads.' ]
  ]
end

Instance Method Details

#call(env) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/leafy/rack/thread_dump.rb', line 47

def call(env)
  if env['PATH_INFO'] == @path
    ThreadDump.response
  else
    @app.call( env )
  end
end