Files
openfoodnetwork/app/controllers/concerns/request_timeouts.rb
2021-10-25 21:28:28 -05:00

27 lines
587 B
Ruby

# frozen_string_literal: true
module RequestTimeouts
extend ActiveSupport::Concern
included do
if defined? Rack::Timeout
rescue_from Rack::Timeout::RequestTimeoutException,
with: :timeout_response
end
end
private
def timeout_response(_exception = nil)
respond_to do |type|
type.html {
render status: :gateway_timeout,
file: Rails.root.join("public/500.html"),
formats: [:html],
layout: nil
}
type.all { render status: :gateway_timeout, body: nil }
end
end
end