1require 'health_check'
 
2
 
3class HealthCheckMiddleware
  • Complexity 1 » saikuro
4  def initialize(app)
 
5    @app = app
 
6  end
 
7
  • Complexity 2 » saikuro
8  def call(env)
 
 9    if env['PATH_INFO'] =~ %r[\A/health-check/?\Z]
 
10      [
 
11        200,
 
12        {
 
13          'Content-Type' => 'application/json',
 
14        },
 
15        [HealthCheck.checkup(env).to_json]
 
16      ]
 
17    else
 
18      @app.call(env)
 
19    end
 
20  end
 
21end