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.1.5 lib/metatron/controllers/ping.rb
metatron-0.1.4 lib/metatron/controllers/ping.rb
metatron-0.1.3 lib/metatron/controllers/ping.rb
metatron-0.1.2 lib/metatron/controllers/ping.rb
metatron-0.1.1 lib/metatron/controllers/ping.rb
metatron-0.1.0 lib/metatron/controllers/ping.rb