Class: HireFire::Middleware
- Inherits:
-
Object
- Object
- HireFire::Middleware
- Defined in:
- lib/hirefire/middleware.rb
Instance Method Summary collapse
-
#call(env) ⇒ Object
Intercepts and handles the /hirefire/test, /hirefire/development/info, and /hirefire/HIREFIRE_TOKEN/info paths.
-
#initialize(app) ⇒ Middleware
constructor
Initializes HireFire::Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Initializes HireFire::Middleware.
10 11 12 13 14 |
# File 'lib/hirefire/middleware.rb', line 10 def initialize(app) @app = app @token = ENV["HIREFIRE_TOKEN"] @path_prefix = get_path_prefix end |
Instance Method Details
#call(env) ⇒ Object
Intercepts and handles the /hirefire/test, /hirefire/development/info, and /hirefire/HIREFIRE_TOKEN/info paths. If none of these paths match, then then request will continue down the middleware stack.
When HireFire::Resource.log_queue_metrics is enabled, and the HTTP_X_REQUEST_START header has been injected at the Heroku Router layer, queue time information will be logged to STDOUT. This data can be used by the HireFire Logdrain with the Web.Logplex.QueueTime autoscaling strategy.
Important: Don’t set/update instance variables within this- or any underlying methods. Doing so may result in race conditions when using threaded application servers.
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hirefire/middleware.rb', line 30 def call(env) handle_queue(env["HTTP_X_REQUEST_START"]) if test_path?(env["PATH_INFO"]) build_test_response elsif info_path?(env["PATH_INFO"]) build_info_response else @app.call(env) end end |