forked from pragmaticly/teahour.fm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ru
36 lines (29 loc) · 759 Bytes
/
config.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require "rack"
require "rack/contrib/try_static"
require 'rack/contrib/static_cache'
# require "middleman"
# require "middleman/builder"
# Middleman::Builder.start
module Heroku
class StaticAssetsMiddleware
def initialize(app)
@app = app
end
def call(env)
@app.call(env)
end
end
end
use Rack::TryStatic,
:root => 'build',
:urls => ['/'],
:try => ['.html', 'index.html', '/index.html']
use Rack::StaticCache, urls: ['/'], root: 'build'
run lambda{ |env|
not_found_page = File.expand_path("../build/404.html", __FILE__)
if File.exist?(not_found_page)
[ 404, { 'Content-Type' => 'text/html'}, [File.read(not_found_page)] ]
else
[ 404, { 'Content-Type' => 'text/html' }, ['File not found!'] ]
end
}