class RackGraphql::HealthResponseBuilder

Attributes

app_name[R]
request[R]

Public Class Methods

new(app_name:, env: {}) click to toggle source
# File lib/rack_graphql/health_response_builder.rb, line 3
def initialize(app_name:, env: {})
  @app_name = app_name
  @request = Rack::Request.new(env)
end

Public Instance Methods

build() click to toggle source
# File lib/rack_graphql/health_response_builder.rb, line 8
def build
  [200, headers, [body]]
end

Private Instance Methods

body() click to toggle source
# File lib/rack_graphql/health_response_builder.rb, line 20
def body
  Oj.dump(
    'status'     => 'ok',
    'request_ip' => request.ip,
    'app_name'   => app_name,
    'app_env'    => ENV['RACK_ENV'],
    'host'       => ENV['HOSTNAME'],
    'revision'   => ENV['REVISION']
  )
end
headers() click to toggle source
# File lib/rack_graphql/health_response_builder.rb, line 16
def headers
  { 'Content-Type' => 'application/json' }
end