class Shutterbug::Handlers::FileHandler

Public Class Methods

path_prefix() click to toggle source

relative url

# File lib/shutterbug/handlers/file_handler.rb, line 6
def self.path_prefix
  "#{Configuration.instance.path_prefix}/get_file"
end
regex() click to toggle source
# File lib/shutterbug/handlers/file_handler.rb, line 15
def self.regex
  filename_matcher = "(([^\/|\.]+)\.?([^\/]+))?"
  /#{self.path_prefix}\/#{filename_matcher}/
end
uri_prefix() click to toggle source

absolute url

# File lib/shutterbug/handlers/file_handler.rb, line 11
def self.uri_prefix
  "#{Configuration.instance.uri_prefix}#{self.path_prefix}"
end

Public Instance Methods

handle(helper, req, env) click to toggle source
# File lib/shutterbug/handlers/file_handler.rb, line 20
def handle(helper, req, env)
  filename = self.class.regex.match(req.path)[1]
  if File.extname(filename) == ''
    filename += '.html'
  end
  file = Configuration.instance.storage.new(filename)
  helper.response(file.get_content, file.mime_type)
end