class ActionDispatch::Static

requests will result in a file being returned.
produce a directory traversal using this middleware. Only ‘GET’ and ‘HEAD’
living in the root directory can be rendered. A request cannot
This middleware verifies the path to ensure that only files
to serve assets from a server’s public/ directory.
delegated to the application stack. This middleware is commonly initialized
disk in the response. If a file is not found on disk, the request will be
This middleware will attempt to return the contents of a file’s body from

def call(env)

def call(env)
  req = Rack::Request.new env
  if req.get? || req.head?
    path = req.path_info.chomp("/".freeze)
    if match = @file_handler.match?(path)
      req.path_info = match
      return @file_handler.serve(req)
    end
  end
  @app.call(req.env)
end

def initialize(app, path, index: "index", headers: {})

def initialize(app, path, index: "index", headers: {})
  @app = app
  @file_handler = FileHandler.new(path, index: index, headers: headers)
end