Added static file serving from public/.

This commit is contained in:
Paul van Tilburg 2011-11-03 11:00:35 +01:00
parent 614e73bad1
commit 9b8f2368fd
1 changed files with 15 additions and 1 deletions

View File

@ -13,6 +13,7 @@
require "active_support"
require "camping"
require "markaby"
require "mime/types"
require "pathname"
Markaby::Builder.set(:indent, 2)
@ -254,7 +255,20 @@ module StopTime::Controllers
render :invoices
end
end
class StaticX
def get(path)
mime_type = MIME::Types.type_for(path).first
@headers['Content-Type'] = mime_type.nil? ? "text/plain" : mime_type.to_s
unless path.include? ".."
@headers['X-Sendfile'] = (BASE_DIR + path).to_s
else
@status = "403"
"Error 403: Invalid path: #{path}"
end
end
end
end # module StopTime::Controllers
module StopTime::Views