Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

[It's now part of rack-contrib ] try to find a file to serve with rack-static!

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 rack-try_static.gemspec
README.md

How to

Install gem

gem install rack-try_static

Add Rack::TryStatic middleware to your config.ru(stack):

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']]}

Profit!

About

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

Examples

Blogging with Jekyll and Heroku for free.

TODO

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