Sha256: 560438b12c96a8d4ee7b7bef6c4f4f1aa2bfdaa070448b88b043be470058ac2f
Contents?: true
Size: 1.39 KB
Versions: 4
Compression:
Stored size: 1.39 KB
Contents
# frozen-string-literal: true # class Roda module RodaPlugins # The heartbeat handles heartbeat/status requests. If a request for # the heartbeat path comes in, a 200 response with a # text/plain Content-Type and a body of "OK" will be returned. # The default heartbeat path is "/heartbeat", so to use that: # # plugin :heartbeat # # You can also specify a custom heartbeat path: # # plugin :heartbeat, path: '/status' module Heartbeat # :nocov: HEADER_CLASS = (defined?(Rack::Headers) && Rack::Headers.is_a?(Class)) ? Rack::Headers : Hash # :nocov: private_constant :HEADER_CLASS HEARTBEAT_RESPONSE = [200, {'Content-Type'=>'text/plain'}.freeze, ['OK'.freeze].freeze].freeze # Set the heartbeat path to the given path. def self.configure(app, opts=OPTS) app.opts[:heartbeat_path] = (opts[:path] || app.opts[:heartbeat_path] || "/heartbeat").dup.freeze end module InstanceMethods private # If the request is for a heartbeat path, return the heartbeat response. def _roda_before_20__heartbeat if env['PATH_INFO'] == opts[:heartbeat_path] response = HEARTBEAT_RESPONSE.dup response[1] = HEADER_CLASS[response[1]] throw :halt, response end end end end register_plugin(:heartbeat, Heartbeat) end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
roda-3.57.0 | lib/roda/plugins/heartbeat.rb |
roda-3.56.0 | lib/roda/plugins/heartbeat.rb |
roda-3.55.0 | lib/roda/plugins/heartbeat.rb |
roda-3.54.0 | lib/roda/plugins/heartbeat.rb |