Class: Fluther::Proxy

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

Instance Method Summary collapse

Constructor Details

#initialize(app, prefix) ⇒ Proxy

Returns a new instance of Proxy.



7
8
9
10
# File 'lib/fluther/proxy.rb', line 7

def initialize( app, prefix )
  @app, @prefix = app, prefix
  @prefix = "/#{@prefix}"  unless @prefix.starts_with?('/')
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fluther/proxy.rb', line 12

def call( env )
  return @app.call( env )  unless env['PATH_INFO'] =~ %r{^#{@prefix}}
  @in_req = Rack::Request.new env

  @user = {}
  if user = @in_req.env['warden'].authenticate rescue nil
    @user = Hash[ Fluther::Config.user_fields.map { |dest, src|  [dest, user.send(src).to_s] } ]
  end

  exec_request
end