Sha256: de0578ead924bbad82f6784d8c5be19629c4b988d6abe1cf2bff08cbd4043cbe
Contents?: true
Size: 776 Bytes
Versions: 2
Compression:
Stored size: 776 Bytes
Contents
# Attempt to serve static files from public directory. Throws :halt when # a matching file is found, returns nil otherwise. def static! return if (public_dir = settings.public).nil? public_dir = File.expand_path(public_dir) path = File.expand_path(public_dir + unescape(request.path_info)) return if path[0, public_dir.length] != public_dir return unless File.file?(path) env['sinatra.static_file'] = path send_file path, :disposition => nil end # Dispatch a request with error handling. def dispatch! static! if settings.static? && (request.get? || request.head?) filter! :before route! rescue NotFound => boom handle_not_found!(boom) rescue ::Exception => boom handle_exception!(boom) ensure filter! :after unless env['sinatra.static_file'] end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
crystal-0.0.3 | lib/crystal/rack/middleware/static_files.rb |
crystal-0.0.2 | lib/crystal/rack/middleware/static_files.rb |