module Qeweney::ResponseMethods
def serve_file(path, opts = {})
def serve_file(path, opts = {}) full_path = file_full_path(path, opts) stat = File.stat(full_path) etag = StaticFileCaching.file_stat_to_etag(stat) last_modified = StaticFileCaching.file_stat_to_last_modified(stat) if validate_static_file_cache(etag, last_modified) return respond(nil, { ':status' => Status::NOT_MODIFIED, 'etag' => etag }) end mime_type = Qeweney::MimeTypes[File.extname(path)] opts[:stat] = stat (opts[:headers] ||= {})['Content-Type'] ||= mime_type if mime_type respond_with_static_file(full_path, etag, last_modified, opts) rescue Errno::ENOENT respond(nil, ':status' => Status::NOT_FOUND) end