Sha256: 3abeda0234201dec45570741917ff6c4cea9769efe3529023aabc26b29a21f3d

Contents?: true

Size: 480 Bytes

Versions: 2

Compression:

Stored size: 480 Bytes

Contents

require "sinatra/base"

module Health
  class Endpoint < Sinatra::Base
    before do
      content_type "application/json"

      if !instance_eval(&Health.endpoint_access_policy)
        halt "Access denied."
      end
    end

    get "/" do
      Health.names.to_json
    end

    get "/:name" do
      pass if !Health.has_check?(params[:name])

      value = Health.perform(params[:name])
      status = value[:ok] ? 200 : 500

      [status, value.to_json]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
health-0.0.4 lib/health/endpoint.rb
health-0.0.3 lib/health/endpoint.rb