Skip to content

Commit

Permalink
Use Rack::Files, not Rack::File
Browse files Browse the repository at this point in the history
The latter is deprecated.

Fixes #30.
  • Loading branch information
denisdefreyne committed Oct 3, 2023
1 parent 3a83ada commit 22d45fe
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The `Adsf::Rack::IndexFileFinder` middleware makes Rack load an index file (e.g.

```ruby
use Adsf::Rack::IndexFileFinder, root: 'public'
run Rack::File.new('public')
run Rack::Files.new('public')
```

It takes the following options:
Expand All @@ -48,12 +48,12 @@ It takes the following options:
use Adsf::Rack::IndexFileFinder,
root: 'public',
index_filenames: %w[index.html index.xhtml]
run Rack::File.new('public')
run Rack::Files.new('public')
```

**Why not use `Rack::Static`?** Rack comes with `Rack::Static`, whose purpose is similar to, but not the same as, `Adsf::Rack::IndexFileFinder`. In particular:

- `Adsf::Rack::IndexFileFinder` does not serve files, unlike `Rack::Static`. `IndexFileFinder` only rewrites the incoming request and passes it on (usually to `Rack::File`).
- `Adsf::Rack::IndexFileFinder` does not serve files, unlike `Rack::Static`. `IndexFileFinder` only rewrites the incoming request and passes it on (usually to `Rack::Files`).

- `Adsf::Rack::IndexFileFinder` supports multiple index files, while `Rack::Static` only supports one (you could have multiple `Rack::Static` middlewares, one for each index filenames, though).

Expand Down
2 changes: 1 addition & 1 deletion adsf/lib/adsf/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def build_app(root:, index_filenames:)
use ::Rack::LiveReload, no_swf: true, source: :vendored
end

run ::Rack::File.new(root)
run ::Rack::Files.new(root)
end.to_app
end

Expand Down
2 changes: 1 addition & 1 deletion adsf/test/rack/test_index_file_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def app
end

def stub_app
Rack::File.new('.')
Rack::Files.new('.')
end

def test_get_file
Expand Down

0 comments on commit 22d45fe

Please sign in to comment.