Skip to content
[It's now part of rack-contrib ] try to find a file to serve with rack-static!
Latest commit 5ac3fe5 Jun 5, 2013 @gmarik Update
Failed to load latest commit information.
lib/rack/contrib A bit of documentation Sep 19, 2010
test A bit of documentation Sep 19, 2010 Update Jun 5, 2013
Rakefile passing tests Sep 19, 2010
rack-try_static.gemspec gem version bumped 0.1.1 Sep 19, 2010

How to

Install gem

gem install rack-try_static

Add Rack::TryStatic middleware to your

require 'rack'
require 'rack/contrib/try_static'

use Rack::TryStatic, 
    :root => "public",  # static files root dir
    :urls => %w[/],     # match all requests 
    :try => ['.html', 'index.html', '/index.html'] # try these postfixes sequentially

# otherwise 404 NotFound
run proc { [404, {'Content-Type' => 'text/html'}, ['whoops! Not Found']]}



TryStatic middleware serves static content trying to find matching file. When match found it gets delegated to Rack::Static to be processed.


Blogging with Jekyll and Heroku for free.


  • √ specs
  • √ docs
  • √ merge to rack-cotrib
Something went wrong with that request. Please try again.