Class: Servo::DirectoryIndex
- Inherits:
-
Object
- Object
- Servo::DirectoryIndex
- Defined in:
- lib/servo/directory_index.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, dir) ⇒ DirectoryIndex
constructor
A new instance of DirectoryIndex.
Constructor Details
#initialize(app, dir) ⇒ DirectoryIndex
Returns a new instance of DirectoryIndex.
5 6 7 8 |
# File 'lib/servo/directory_index.rb', line 5 def initialize(app, dir) @app = app @dir = dir end |
Instance Method Details
#call(env) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/servo/directory_index.rb', line 10 def call(env) index_path = ::File.join(@dir, Rack::Request.new(env).path.split('/'), 'index.html') if ::File.exists?(index_path) return [200, {"Content-Type" => "text/html"}, [::File.read(index_path)]] else @app.call(env) end end |