Class: Brite::Server::Index
- Inherits:
-
Object
- Object
- Brite::Server::Index
- Defined in:
- lib/brite/server.rb
Overview
Rack middleware to serve ‘index.html` file by default.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, root) ⇒ Index
constructor
A new instance of Index.
Constructor Details
Instance Method Details
#call(env) ⇒ Object
113 114 115 116 117 118 119 120 121 |
# File 'lib/brite/server.rb', line 113 def call(env) path = Rack::Utils.unescape(env['PATH_INFO']) index_file = File.join(@root, path, 'index.html') if File.exists?(index_file) [200, {'Content-Type' => 'text/html'}, File.new(index_file)] else @app.call(env) #Rack::Directory.new(@root).call(env) end end |