Class: Spar::Rewrite
- Inherits:
-
Object
- Object
- Spar::Rewrite
- Defined in:
- lib/spar/rewrite.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Rewrite
constructor
A new instance of Rewrite.
Constructor Details
#initialize(app) ⇒ Rewrite
Returns a new instance of Rewrite.
8 9 10 |
# File 'lib/spar/rewrite.rb', line 8 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/spar/rewrite.rb', line 12 def call(env) if env['HTTP_ACCEPT'] =~ /text\/html/ if env['PATH_INFO'] == '/' env['PATH_INFO'] = '/index.html' else unless env['PATH_INFO'] =~ /\.[a-zA-Z]+$/ env['PATH_INFO'] << '.html' end end end @app.call(env) end |