Class: TrackerHub::Request::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/tracker_hub/request/middleware.rb

Overview

Middleware to include in a Rails stack to log every incoming requests

Instance Method Summary collapse

Instance Method Details

#call(env) ⇒ Array

Method called by the middleware stack to run the request tracker


15
16
17
18
19
20
21
22
# File 'lib/tracker_hub/request/middleware.rb', line 15

def call(env)
  # execute application to get more data (injected into env)
  status, headers, body = @app.call(env)
  # save logs from env
  track(env, status, headers)
  # release the process to other middlewares
  [status, headers, body]
end