Class: Tuttle::Middleware::RequestProfiler
- Inherits:
-
Object
- Object
- Tuttle::Middleware::RequestProfiler
- Defined in:
- lib/tuttle/middleware/request_profiler.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ RequestProfiler
constructor
A new instance of RequestProfiler.
Constructor Details
#initialize(app) ⇒ RequestProfiler
Returns a new instance of RequestProfiler.
7 8 9 |
# File 'lib/tuttle/middleware/request_profiler.rb', line 7 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tuttle/middleware/request_profiler.rb', line 11 def call(env) query_string = env['QUERY_STRING'] tuttle_profiler_action = /(^|[&?])tuttle-profiler=([\w\-]*)/.match(query_string) { |m| m[2] } case tuttle_profiler_action when 'memory_profiler', 'memory' profile_memory(env, query_string) when 'ruby-prof', 'cpu' profile_cpu(env, query_string) when 'busted' profile_busted(env, query_string) else @app.call(env) end end |