Class: StackProf::Remote::Middleware
- Inherits:
-
Object
- Object
- StackProf::Remote::Middleware
- Defined in:
- lib/stackprof/remote/middleware.rb
Overview
Middleware is a simple Rack middleware that handles requests to urls matching /__stackprof__ for starting/stopping a profile session and retreiving the dump files. It delegates to the ProcessReportCollector to do the actual work of collecting and combining the dumps.
Class Attribute Summary collapse
-
.enabled ⇒ Object
Returns the value of attribute enabled.
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.options ⇒ Object
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app, options = {}) ⇒ Middleware
Returns a new instance of Middleware.
24 25 26 27 28 29 |
# File 'lib/stackprof/remote/middleware.rb', line 24 def initialize(app, = {}) @app = app self.class.logger = .delete(:logger) || Logger.new(STDOUT) self.class. = logger.info "[stackprof] Stackprof Middleware enabled" end |
Class Attribute Details
.enabled ⇒ Object
Returns the value of attribute enabled.
13 14 15 |
# File 'lib/stackprof/remote/middleware.rb', line 13 def enabled @enabled end |
.logger ⇒ Object
Returns the value of attribute logger.
13 14 15 |
# File 'lib/stackprof/remote/middleware.rb', line 13 def logger @logger end |
.options ⇒ Object
Returns the value of attribute options.
13 14 15 |
# File 'lib/stackprof/remote/middleware.rb', line 13 def end |
Class Method Details
.enabled?(env) ⇒ Boolean
15 16 17 18 19 20 21 |
# File 'lib/stackprof/remote/middleware.rb', line 15 def enabled?(env) if enabled.respond_to?(:call) enabled.call(env) else enabled end end |
Instance Method Details
#call(env) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/stackprof/remote/middleware.rb', line 31 def call(env) path = env['PATH_INFO'] if in_stackprof?(path) handle_stackprof(path) else @app.call(env) end end |