Software: Apache. PHP/7.3.33 uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) Safe-mode: OFF (not secure) /opt/alt/ruby18/lib64/ruby/gems/1.8/doc/rack-1.6.1/rdoc/classes/Rack/ drwxr-xr-x |
Viewing file: Select action/file-type:
The Rack::Static middleware intercepts requests for static files (javascript files, images, stylesheets, etc) based on the url prefixes or route mappings passed in the options, and serves them using a Rack::File object. This allows a Rack stack to serve both static and dynamic content. Examples: Serve all requests beginning with /media from the "media" folder located in the current directory (ie media/*): use Rack::Static, :urls => ["/media"] Serve all requests beginning with /css or /images from the folder "public" in the current directory (ie public/css/* and public/images/*): use Rack::Static, :urls => ["/css", "/images"], :root => "public" Serve all requests to / with "index.html" from the folder "public" in the current directory (ie public/index.html): use Rack::Static, :urls => {"/" => 'index.html'}, :root => 'public' Serve all requests normally from the folder "public" in the current directory but uses index.html as default route for "/" use Rack::Static, :urls => [""], :root => 'public', :index => 'index.html' Set custom HTTP Headers for based on rules: use Rack::Static, :root => 'public', :header_rules => [ [rule, {header_field => content, header_field => content}], [rule, {header_field => content}] ] Rules for selecting files: 1) All files Provide the :all symbol :all => Matches every file 2) Folders Provide the folder path as a string '/folder' or '/folder/subfolder' => Matches files in a certain folder 3) File Extensions Provide the file extensions as an array ['css', 'js'] or %w(css js) => Matches files ending in .css or .js 4) Regular Expressions / Regexp Provide a regular expression %r{\.(?:css|js)\z} => Matches files ending in .css or .js /\.(?:eot|ttf|otf|woff|svg)\z/ => Matches files ending in the most common web font formats (.eot, .ttf, .otf, .woff, .svg) Note: This Regexp is available as a shortcut, using the :fonts rule 5) Font Shortcut Provide the :fonts symbol :fonts => Uses the Regexp rule stated right above to match all common web font endings Rule Ordering: Rules are applied in the order that they are provided. List rather general rules above special ones. Complete example use case including HTTP header rules: use Rack::Static, :root => 'public', :header_rules => [ # Cache all static files in public caches (e.g. Rack::Cache) # as well as in the browser [:all, {'Cache-Control' => 'public, max-age=31536000'}], # Provide web fonts with cross-origin access-control-headers # Firefox requires this when serving assets using a Content Delivery Network [:fonts, {'Access-Control-Allow-Origin' => '*'}] ] Public Class methodsPublic Instance methods |
:: Command execute :: | |
--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0974 ]-- |