module Flame::Dispatcher::Static

Module for working with static files

Public Instance Methods

find_static(filename = request.path_info, dir: config[:public_dir]) click to toggle source
# File lib/flame/dispatcher/static.rb, line 7
def find_static(filename = request.path_info, dir: config[:public_dir])
        StaticFile.new(filename, dir)
end

Private Instance Methods

return_static(file) click to toggle source
# File lib/flame/dispatcher/static.rb, line 20
def return_static(file)
        halt 304 if file.newer? request.env['HTTP_IF_MODIFIED_SINCE']
        response.content_type = file.extname
        response[Rack::CACHE_CONTROL] = 'no-cache'
        response['Last-Modified'] = file.mtime.httpdate
        body file.content
end
try_static(*args) click to toggle source

Find static files and try return it

# File lib/flame/dispatcher/static.rb, line 14
def try_static(*args)
        file = find_static(*args)
        return nil unless file.exist?
        return_static(file)
end