Class: Spore::Middleware::Runtime

Inherits:
Spore::Middleware show all
Defined in:
lib/spore/middleware/runtime.rb

Instance Method Summary collapse

Methods inherited from Spore::Middleware

#expected_params, #initialize

Constructor Details

This class inherits a constructor from Spore::Middleware

Instance Method Details

#process_request(env) ⇒ Object



6
7
8
9
# File 'lib/spore/middleware/runtime.rb', line 6

def process_request(env)
  env['sporex.runtime.start'] = Time.now
  return nil
end

#process_response(resp, env) ⇒ Object



11
12
13
14
15
16
# File 'lib/spore/middleware/runtime.rb', line 11

def process_response(resp, env)
  elapsed_time = Time.now - env['sporex.runtime.start']

  resp.header['X-Spore-Runtime'] = elapsed_time
  return resp
end