Created
March 16, 2017 02:10
-
-
Save coffeejay/ae310bb24c00f5af126f8f5898f619ec to your computer and use it in GitHub Desktop.
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
| use Rack::Static, | |
| :urls => ["/images", "/js", "/css", "/fonts"], | |
| :root => "public" | |
| run lambda { |env| | |
| request = Rack::Request.new(env) | |
| file = request.env['REQUEST_URI'].match(/([^\/]+)(?=\.\w+$)/) | |
| file = file ? file[0] : "index" | |
| [ | |
| 200, | |
| { | |
| 'Content-Type' => 'text/html', | |
| 'Cache-Control' => 'public, max-age=86400' | |
| }, | |
| File.open("public/#{file}.html", File::RDONLY) | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment