Class: Bowtie::Middleware::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/bowtie/middleware/proxy.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Proxy

Returns a new instance of Proxy.



3
4
5
6
# File 'lib/bowtie/middleware/proxy.rb', line 3

def initialize(*args)
  @platform = Platform.new
  @backend  = Backend.new
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/bowtie/middleware/proxy.rb', line 8

def call(env)
  status, headers, body = @platform.call(env)

  if status.to_i == 305
    env[:proxy_addon_headers] = JSON.load(headers['X-Bowtie-Client-Proxy-Headers'].first)
    env[:proxy_location] = headers['Location'].first
    @backend.call(env)
  else
    [status, headers, body]
  end
end