Based on original presentation by Dan Webb http://slidesha.re/dan_on_rack
Added some bits about Rails at the end, instead of other examples he had originally.
22. class StreamingFile
def initialize(file)
@file = file
end
def length
File.size(@file)
end
def last_modified
File.mtime(@file).rfc822
end
def each
File.open(@file, "rb")
do |file|
while part = file.read(8192)
yield part
end
File.delete(@file)
end
end
34. config.ru
# This file is used by Rack-based servers to start
the application.
require ::File.expand_path('../config/environment',
__FILE__)
run MyApp::Application
35. routes.rb
# You can call any Rack app from a route
match "/foo" => MySinatraApp
match "/bar" => MyMiddleware.new(OtherApp)