Class: Rack::Initforthe::Facebook::AppDataRedirect

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/initforthe/facebook/app_data_redirect.rb

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of AppDataRedirect.



5
6
7
# File 'lib/rack/initforthe/facebook/app_data_redirect.rb', line 5

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

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/rack/initforthe/facebook/app_data_redirect.rb', line 9

def call(env)
  signed_params = env['facebook.signed_request'] || {}
  url = signed_params['app_data'].to_s
  if url[0] == '/'
    # Not sure what status code is applicable here really, this seems closest.
    [303, { 'Location' => url }, ['Redirecting']]
  else
    @app.call(env)
  end
end