Class: Gitlab::HealthChecks::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/health_checks/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, readiness_probe, liveness_probe) ⇒ Middleware

Returns a new instance of Middleware.


6
7
8
9
10
# File 'lib/gitlab/health_checks/middleware.rb', line 6

def initialize(app, readiness_probe, liveness_probe)
  @app = app
  @readiness_probe = readiness_probe
  @liveness_probe = liveness_probe
end

Instance Method Details

#call(env) ⇒ Object


12
13
14
15
16
17
18
# File 'lib/gitlab/health_checks/middleware.rb', line 12

def call(env)
  case env['PATH_INFO']
  when '/readiness' then render_probe(@readiness_probe)
  when '/liveness' then render_probe(@liveness_probe)
  else @app.call(env)
  end
end