class Embork::Pushstate

Attributes

app[R]

Public Class Methods

new(app, options = {}) click to toggle source
# File lib/embork/pushstate.rb, line 3
def initialize(app, options = {})
  @app = app
end

Public Instance Methods

call(env) click to toggle source
# 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