From 504ca940159891633799bb490836658614c684d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Joubert?= Date: Mon, 13 Nov 2023 23:17:18 +0100 Subject: [PATCH 1/2] Handle deprecation of Rack::File in Rack 3.1 When using Rack >= 3.0.0 you get this error message on boot an app with Flipper UI : ``` warning: Rack::File is deprecated and will be removed in Rack 3.1 ``` This PR detects if `Rack::Files` is defined and tries to use it instead. Source : https://github.com/rack/rack/pull/1720 --- lib/flipper/ui/actions/file.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/flipper/ui/actions/file.rb b/lib/flipper/ui/actions/file.rb index 7a8089515..2e55a0d48 100644 --- a/lib/flipper/ui/actions/file.rb +++ b/lib/flipper/ui/actions/file.rb @@ -8,7 +8,8 @@ class File < UI::Action route %r{(images|css|js)/.*\Z} def get - Rack::File.new(public_path).call(request.env) + klass = Rack.release >= "2.1" ? Rack::Files : Rack::File + klass.new(public_path).call(request.env) end end end From 1fd5292fb97bb5c8bd4fa0469e5777ea6ae25e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Joubert?= Date: Thu, 16 Nov 2023 21:32:01 +0100 Subject: [PATCH 2/2] Use the Rack release version to require the appropriate part of Rack --- lib/flipper/ui/actions/file.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/flipper/ui/actions/file.rb b/lib/flipper/ui/actions/file.rb index 2e55a0d48..4ed0a5a34 100644 --- a/lib/flipper/ui/actions/file.rb +++ b/lib/flipper/ui/actions/file.rb @@ -1,4 +1,8 @@ -require 'rack/file' +if Rack.release >= "2.1" + require 'rack/files' +else + require 'rack/file' +end require 'flipper/ui/action' module Flipper