Sha256: abce2aa26f1c8cb830db79a43f4c084324f4e0833240ee0310febe8e969c0739

Contents?: true

Size: 680 Bytes

Versions: 9

Compression:

Stored size: 680 Bytes

Contents

module Goliath
  module Rack
    # A heartbeat mechanism for the server. This will add a _/status_ endpoint
    # that returns status 200 and content OK when executed.
    #
    # @example
    #  use Goliath::Rack::Heartbeat
    #
    class Heartbeat
      def initialize(app, opts = {})
        @app  = app
        @opts = opts
        @opts[:path]     ||= '/status'
        @opts[:response] ||= [200, {}, 'OK']
      end

      def call(env)
        if env['PATH_INFO'] == @opts[:path]
          env[Goliath::Constants::RACK_LOGGER] = Log4r::Logger.root unless @opts[:log]
          @opts[:response]
        else
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
goliath-1.0.7 lib/goliath/rack/heartbeat.rb
goliath-1.0.6 lib/goliath/rack/heartbeat.rb
goliath-1.0.5 lib/goliath/rack/heartbeat.rb
goliath-1.0.4 lib/goliath/rack/heartbeat.rb
goliath-1.0.3 lib/goliath/rack/heartbeat.rb
goliath-1.0.2 lib/goliath/rack/heartbeat.rb
goliath-1.0.1 lib/goliath/rack/heartbeat.rb
goliath-1.0.0 lib/goliath/rack/heartbeat.rb
goliath-1.0.0.beta.1 lib/goliath/rack/heartbeat.rb