lib/roda/plugins/heartbeat.rb in roda-3.57.0 vs lib/roda/plugins/heartbeat.rb in roda-3.58.0

- old
+ new

@@ -12,17 +12,10 @@ # # 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 @@ -30,12 +23,14 @@ 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 + response = @_response + response.status = 200 + response['Content-Type'] = 'text/plain' + response.write 'OK' + throw :halt, response.finish end end end end