관리-도구
편집 파일: cdesc-Static.ri
U:RDoc::NormalClass[iI"Static:EFI"Rack::Static;FI"Object;To:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[ I"FThe Rack::Static middleware intercepts requests for static files ;TI"O(javascript files, images, stylesheets, etc) based on the url prefixes or ;TI"Nroute mappings passed in the options, and serves them using a Rack::File ;TI"Oobject. This allows a Rack stack to serve both static and dynamic content.;To:RDoc::Markup::BlankLine o; ;[I"Examples:;T@o; ;[I"NServe all requests beginning with /media from the "media" folder located ;TI"+in the current directory (ie media/*):;T@o:RDoc::Markup::Verbatim;[I"+use Rack::Static, :urls => ["/media"] ;T:@format0o; ;[I"PServe all requests beginning with /css or /images from the folder "public" ;TI"Din the current directory (ie public/css/* and public/images/*):;T@o;;[I"Guse Rack::Static, :urls => ["/css", "/images"], :root => "public" ;T;0o; ;[I"OServe all requests to / with "index.html" from the folder "public" in the ;TI".current directory (ie public/index.html):;T@o;;[I"Iuse Rack::Static, :urls => {"/" => 'index.html'}, :root => 'public' ;T;0o; ;[I"IServe all requests normally from the folder "public" in the current ;TI";directory but uses index.html as default route for "/";T@o;;[I"Cuse Rack::Static, :urls => [""], :root => 'public', :index => ;TI"'index.html' ;T;0o; ;[I"0Set custom HTTP Headers for based on rules:;T@o;;[4I"- use Rack::Static, :root => 'public', ;TI" :header_rules => [ ;TI"J [rule, {header_field => content, header_field => content}], ;TI"0 [rule, {header_field => content}] ;TI" ] ;TI" ;TI" Rules for selecting files: ;TI" ;TI"1) All files ;TI" Provide the :all symbol ;TI"# :all => Matches every file ;TI" ;TI"2) Folders ;TI", Provide the folder path as a string ;TI"N '/folder' or '/folder/subfolder' => Matches files in a certain folder ;TI" ;TI"3) File Extensions ;TI"0 Provide the file extensions as an array ;TI"K ['css', 'js'] or %w(css js) => Matches files ending in .css or .js ;TI" ;TI"%4) Regular Expressions / Regexp ;TI"% Provide a regular expression ;TI"B %r{\.(?:css|js)\z} => Matches files ending in .css or .js ;TI"H /\.(?:eot|ttf|otf|woff2|woff|svg)\z/ => Matches files ending in ;TI"S the most common web font formats (.eot, .ttf, .otf, .woff2, .woff, .svg) ;TI"N Note: This Regexp is available as a shortcut, using the :fonts rule ;TI" ;TI"5) Font Shortcut ;TI"" Provide the :fonts symbol ;TI"_ :fonts => Uses the Regexp rule stated right above to match all common web font endings ;TI" ;TI"Rule Ordering: ;TI"> Rules are applied in the order that they are provided. ;TI"5 List rather general rules above special ones. ;TI" ;TI"<Complete example use case including HTTP header rules: ;TI" ;TI"- use Rack::Static, :root => 'public', ;TI" :header_rules => [ ;TI"K # Cache all static files in public caches (e.g. Rack::Cache) ;TI"+ # as well as in the browser ;TI"G [:all, {'Cache-Control' => 'public, max-age=31536000'}], ;TI" ;TI"K # Provide web fonts with cross-origin access-control-headers ;TI"\ # Firefox requires this when serving assets using a Content Delivery Network ;TI"? [:fonts, {'Access-Control-Allow-Origin' => '*'}] ;TI" ];T;0: @fileI"lib/rack/static.rb;T:0@omit_headings_from_table_of_contents_below0; 0;0[ [ [ [[I" class;T[[:public[[I"new;TI"lib/rack/static.rb;T[:protected[ [:private[ [I" instance;T[[;[ [I"applicable_rules;F@u[I" call;F@u[I"can_serve;F@u[I"overwrite_file_path;F@u[I"route_file;F@u[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ; 0;0[@iI" Rack;FcRDoc::NormalModule