Method: HttpRouter::Route#static
- Defined in:
- lib/http_router/route.rb
#static(root) ⇒ Object
Sets the destination of this route to serve static files from either a directory or a single file.
210 211 212 213 214 215 216 217 |
# File 'lib/http_router/route.rb', line 210 def static(root) if File.directory?(root) partial.to ::Rack::File.new(root) else to proc{|env| env['PATH_INFO'] = File.basename(root); ::Rack::File.new(File.dirname(root)).call(env)} end self end |