instance method find_file

Ruby on Rails 7.1.6

Since v6.1.7.10 Private

Available in: v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

find_file(path_info, accept_encoding:)

Match a URI path to a static file to be served.

Used by the Static class to negotiate a servable file in the public/ directory (see Static#call).

Checks for path, path.html, and path/index.html files, in that order, including .br and .gzip compressed extensions.

If a matching file is found, the path and necessary response headers (Content-Type, Content-Encoding) are returned.

Parameters

path_info req
accept_encoding keyreq
Source
# File actionpack/lib/action_dispatch/middleware/static.rb, line 102
      def find_file(path_info, accept_encoding:)
        each_candidate_filepath(path_info) do |filepath, content_type|
          if response = try_files(filepath, content_type, accept_encoding: accept_encoding)
            return response
          end
        end
      end

Defined in actionpack/lib/action_dispatch/middleware/static.rb line 102 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionDispatch::FileHandler

Type at least 2 characters to search.

↑↓ navigate · open · esc close