Skip to content

Commit

Permalink
Fix usage of deprecated Rack::File in Rack 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesds committed Oct 11, 2023
1 parent 7cc859e commit f29badd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/apipie/static_dispatcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ class FileHandler
def initialize(root)
@root = root.chomp('/')
@compiled_root = /^#{Regexp.escape(root)}/
@file_server = ::Rack::File.new(@root)
@file_server = if defined?(::Rack::Files)
::Rack::Files.new(@root)
else
# Deprecated in Rack 3.0, kept
# for backward compatibility
::Rack::File.new(@root)
end
end

def match?(path)
Expand Down

0 comments on commit f29badd

Please sign in to comment.