Class: Embork::Forwarder

Inherits:
Object
  • Object
show all
Defined in:
lib/embork/forwarder.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Forwarder

Returns a new instance of Forwarder.



11
12
13
# File 'lib/embork/forwarder.rb', line 11

def initialize(app, options = {})
  @app = app
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



10
11
12
# File 'lib/embork/forwarder.rb', line 10

def app
  @app
end

Class Method Details

.targetObject



2
3
4
# File 'lib/embork/forwarder.rb', line 2

def self.target
  @target
end

.target=(target) ⇒ Object



6
7
8
# File 'lib/embork/forwarder.rb', line 6

def self.target=(target)
  @target = target
end

Instance Method Details

#call(env) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/embork/forwarder.rb', line 15

def call(env)
  status, headers, body = @app.call(env)
  if status == 404
    status, headers, body = self.class.target.new(@app).call(env)
    headers['Push-State-Redirect'] = 'true'
  end
  [ status, headers, body ]
end