Sha256: fcceaddbd3cbb54529a7065cd2241179018ea323d7aebc953120609d0115de4f

Contents?: true

Size: 724 Bytes

Versions: 26

Compression:

Stored size: 724 Bytes

Contents

# frozen_string_literal: true

module Metatron
  module Controllers
    # Healthcheck service
    class Ping < Sinatra::Application
      configure do
        set :logging, true
        set :logger, Metatron::LOGGER
      end

      before do
        content_type "application/json"

        halt 403 unless request.get? || request.options?

        if request.get?
          headers "X-Frame-Options" => "SAMEORIGIN"
          headers "X-XSS-Protection" => "1; mode=block"
        end
      end

      after do
        headers "Access-Control-Allow-Methods" => %w[GET] if request.options?
      end

      get "/" do
        '{ "status": "up" }'
      end

      options "/" do
        halt 200
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
metatron-0.4.1 lib/metatron/controllers/ping.rb
metatron-0.4.0 lib/metatron/controllers/ping.rb
metatron-0.3.4 lib/metatron/controllers/ping.rb
metatron-0.3.3 lib/metatron/controllers/ping.rb
metatron-0.3.2 lib/metatron/controllers/ping.rb
metatron-0.3.1 lib/metatron/controllers/ping.rb
metatron-0.3.0 lib/metatron/controllers/ping.rb
metatron-0.2.8 lib/metatron/controllers/ping.rb
metatron-0.2.7 lib/metatron/controllers/ping.rb
metatron-0.2.6 lib/metatron/controllers/ping.rb
metatron-0.2.5 lib/metatron/controllers/ping.rb
metatron-0.2.4 lib/metatron/controllers/ping.rb
metatron-0.2.3 lib/metatron/controllers/ping.rb
metatron-0.2.2 lib/metatron/controllers/ping.rb
metatron-0.2.1 lib/metatron/controllers/ping.rb
metatron-0.2.0 lib/metatron/controllers/ping.rb
metatron-0.1.9 lib/metatron/controllers/ping.rb
metatron-0.1.8 lib/metatron/controllers/ping.rb
metatron-0.1.7 lib/metatron/controllers/ping.rb
metatron-0.1.6 lib/metatron/controllers/ping.rb