Sha256: ccf1dc911cdc91203c45dc62be23597c7be17132438dea0668e451f75658c6a0

Contents?: true

Size: 392 Bytes

Versions: 3

Compression:

Stored size: 392 Bytes

Contents

class DirectoryIndex
  def initialize(app)
    @app = app
  end

  def call(env)
    index_path = File.join(
      ".",
      Rack::Request.new(env).path.split('/'),
      "index.html"
    )

    if File.exists?(index_path)
      [200, {"Content-Type" => "text/html"}, [File.read(index_path)]]
    else
      @app.call(env)
    end
  end
end

use DirectoryIndex

run Rack::Directory.new(".")

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tufte-1.1.0 scaffold/config.ru
tufte-1.0.1 scaffold/config.ru
tufte-1.0.0 scaffold/config.ru