Class: FacebookRb::Middleware

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

Overview

This Rack middleware checks the signature of Facebook params and converts them to Ruby objects when appropiate. Also, it converts the request method from the Facebook POST to the original HTTP method used by the client.

Usage

In your rack builder:

use Rack::Facebook, :api_key => "APIKEY", :secret => "SECRET"

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Middleware.



345
346
347
348
# File 'lib/facebookrb.rb', line 345

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

Instance Method Details

#call(env) ⇒ Object



350
351
352
353
354
355
356
357
358
359
360
# File 'lib/facebookrb.rb', line 350

def call(env)
  fb = Client.new(@options)
  fb.extract_params(env)

  env['facebook.client'] = fb

  #env["facebook.original_method"] = env["REQUEST_METHOD"]
  #env["REQUEST_METHOD"] = fb_params['request_method']

  return @app.call(env)
end