0
0
Fork 0

small controller to deliver images

This is nice for development, but should not be used in production. Most
webservers can do better.
This commit is contained in:
Gibheer 2013-10-27 19:46:16 +01:00
parent 5b54051db6
commit fcb995b0f0
1 changed files with 11 additions and 0 deletions

11
controller/image.rb Normal file
View File

@ -0,0 +1,11 @@
module Routes
class Images
def self.call(session)
file = "images/#{session.request.path.gsub(/images/, '')}"
return RouteNotFound unless File.exist?(file)
session.response.body = File.read(file)
session.response.content_type = 'image/png'
nil
end
end
end