1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/lib/middleman/rack/static.rb
tdreyno 58d6fc94ea Revert "update docs"
This reverts commit 43ac01af5c.
2009-10-22 17:25:15 -07:00

21 lines
No EOL
522 B
Ruby

module Middleman
module Rack
class Static
def initialize(app, options={})
@app = app
root = Middleman::Base.public
@file_server = ::Rack::File.new(root)
end
def call(env)
path = env["PATH_INFO"]
file_path = File.join(Middleman::Base.public, path)
if path.include?("favicon.ico") || (File.exists?(file_path) && !File.directory?(file_path))
@file_server.call(env)
else
@app.call(env)
end
end
end
end
end