Class: Embork::Pushstate
- Inherits:
-
Object
- Object
- Embork::Pushstate
- Defined in:
- lib/embork/pushstate.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Pushstate
constructor
A new instance of Pushstate.
Constructor Details
#initialize(app, options = {}) ⇒ Pushstate
Returns a new instance of Pushstate.
3 4 5 |
# File 'lib/embork/pushstate.rb', line 3 def initialize(app, = {}) @app = app end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
2 3 4 |
# File 'lib/embork/pushstate.rb', line 2 def app @app end |
Instance Method Details
#call(env) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/embork/pushstate.rb', line 7 def call(env) status, headers, body = @app.call(env) if status == 404 modified_env = env.dup modified_env['PATH_INFO'] = '/index.html' status, headers, body = @app.call(modified_env) headers['Push-State-Redirect'] = 'true' end [ status, headers, body ] end |