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.
25 26 27 28 29 30 31 |
# File 'lib/stackprof/remote/middleware.rb', line 25 def initialize(app, = {}) @app = app self.class.logger = [:logger] || Logger.new(STDOUT) self.class.enabled = [:enabled] || false self.class. = logger.info "[stackprof] Stackprof Middleware enabled" end |
Class Attribute Details
.enabled ⇒ Object
Returns the value of attribute enabled.
14 15 16 |
# File 'lib/stackprof/remote/middleware.rb', line 14 def enabled @enabled end |
.logger ⇒ Object
Returns the value of attribute logger.
14 15 16 |
# File 'lib/stackprof/remote/middleware.rb', line 14 def logger @logger end |
.options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/stackprof/remote/middleware.rb', line 14 def @options end |
Class Method Details
.enabled?(env) ⇒ Boolean
16 17 18 19 20 21 22 |
# File 'lib/stackprof/remote/middleware.rb', line 16 def enabled?(env) if enabled.respond_to?(:call) enabled.call(env) else enabled end end |
Instance Method Details
#call(env) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/stackprof/remote/middleware.rb', line 33 def call(env) path = env['PATH_INFO'] if self.class.enabled?(env) && in_stackprof?(path) handle_stackprof(path) else @app.call(env) end end |