Created
September 5, 2014 22:53
-
-
Save KamilLelonek/17762ebc5f83ba67a6ec to your computer and use it in GitHub Desktop.
Serving static files from Rack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root = 'public' | |
use Rack::Static, | |
urls: Dir["#{root}/*"].map { |file| file.sub(root, '')}, | |
root: root, | |
index: 'index.html', | |
header_rules: [[:all, { 'Cache-Control' => 'public, max-age=3600' }]] | |
run -> env { | |
[ | |
200, | |
{ | |
'Content-Type' => 'text/html', | |
'Cache-Control' => 'public, max-age=86400' | |
}, | |
File.open("#{root}/index.html", File::RDONLY) | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment