lib/roda/plugins/heartbeat.rb in roda-3.10.0 vs lib/roda/plugins/heartbeat.rb in roda-3.11.0
- old
+ new
@@ -14,23 +14,27 @@
#
# plugin :heartbeat, path: '/status'
module Heartbeat
HEARTBEAT_RESPONSE = [200, {'Content-Type'=>'text/plain'}.freeze, ['OK'.freeze].freeze].freeze
+ def self.load_dependencies(app, opts=OPTS)
+ app.plugin :_before_hook
+ end
+
# 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 call
+ def _roda_before_20
if env['PATH_INFO'] == opts[:heartbeat_path]
response = HEARTBEAT_RESPONSE.dup
response[1] = Hash[response[1]]
- response
- else
- super
+ throw :halt, response
end
end
end
end