Sha256: 7bbeae84fe66b80618b558614d65159f383e9383f8b2beeae422ef960f876b60
Contents?: true
Size: 686 Bytes
Versions: 30
Compression:
Stored size: 686 Bytes
Contents
class Jets::Server class TimingMiddleware FORMAT_STRING = "%0.6f" # :nodoc: HEADER_NAME = "X-Runtime" # :nodoc: def initialize(app) @app = app end def call(env) start_time = clock_time status, headers, body = @app.call(env) request_time = clock_time - start_time unless headers.has_key?(HEADER_NAME) headers[HEADER_NAME] = FORMAT_STRING % request_time end [status, headers, body] end private if defined?(Process::CLOCK_MONOTONIC) def clock_time Process.clock_gettime(Process::CLOCK_MONOTONIC) end else def clock_time Time.now.to_f end end end end
Version data entries
30 entries across 30 versions & 1 rubygems