Class: Jets::Server::TimingMiddleware
- Inherits:
-
Object
- Object
- Jets::Server::TimingMiddleware
- Defined in:
- lib/jets/server/timing_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ TimingMiddleware
constructor
A new instance of TimingMiddleware.
Constructor Details
#initialize(app) ⇒ TimingMiddleware
Returns a new instance of TimingMiddleware.
3 4 5 |
# File 'lib/jets/server/timing_middleware.rb', line 3 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/jets/server/timing_middleware.rb', line 7 def call(env) before = Time.now.to_i status, headers, body = @app.call(env) after = Time.now.to_i = "App took #{after - before} seconds.\n" headers["Timing"] = "App took #{after - before} seconds.\n" [status, headers, body] end |