update for last heroku
This commit is contained in:
parent
c6db9171cd
commit
7ec1549aa4
1 changed files with 25 additions and 1 deletions
26
config.ru
26
config.ru
|
@ -24,6 +24,30 @@ $rootdir="site"
|
|||
$errorFile='site/404.html'
|
||||
$mailFile='site/mail_sent.html'
|
||||
|
||||
|
||||
module ::Rack
|
||||
class TryStatic < Static
|
||||
def initialize(app, options)
|
||||
super
|
||||
@try = ([''] + Array(options.delete(:try)) + [''])
|
||||
end
|
||||
|
||||
def call(env)
|
||||
@next = 0
|
||||
while @next < @try.size && 404 == (resp = super(try_next(env)))[0]
|
||||
@next += 1
|
||||
end
|
||||
404 == resp[0] ? @app.call : resp
|
||||
end
|
||||
|
||||
private
|
||||
def try_next(env)
|
||||
env.merge('PATH_INFO' => env['PATH_INFO'] + @try[@next])
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
class MyMain < Rack::TryStatic
|
||||
def call(env)
|
||||
request = Rack::Request.new(env)
|
||||
|
@ -48,7 +72,7 @@ class MyMain < Rack::TryStatic
|
|||
"Last-Modified" => File.mtime($mailFile).httpdate,
|
||||
"Content-Type" => "text/html",
|
||||
"Content-Length" => File.size($mailFile).to_s
|
||||
}, File.read($mailFile)]
|
||||
}, [File.read($mailFile)]]
|
||||
else
|
||||
super
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue