Parent

Methods

Class Index [+]

Quicksearch

Rack::Runtime

Sets an “X-Runtime” response header, indicating the response time of the request, in seconds

You can put it right before the application to see the processing time, or before all the other middlewares to include time for them, too.

Public Class Methods

new(app, name = nil) click to toggle source
    # File lib/rack/runtime.rb, line 9
 9:     def initialize(app, name = nil)
10:       @app = app
11:       @header_name = "X-Runtime"
12:       @header_name << "-#{name}" if name
13:     end

Public Instance Methods

call(env) click to toggle source
    # File lib/rack/runtime.rb, line 15
15:     def call(env)
16:       start_time = Time.now
17:       status, headers, body = @app.call(env)
18:       request_time = Time.now - start_time
19: 
20:       if !headers.has_key?(@header_name)
21:         headers[@header_name] = "%0.6f" % request_time
22:       end
23: 
24:       [status, headers, body]
25:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.