Sha256: 34f21b9c827acd8cc61a7c9ec9f9ad025ad90f95ce9112cd54832e3d85d2252a

Contents?: true

Size: 723 Bytes

Versions: 2

Compression:

Stored size: 723 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

2 entries across 2 versions & 1 rubygems

Version Path
metatron-0.5.0 lib/metatron/controllers/ping.rb
metatron-0.4.2 lib/metatron/controllers/ping.rb