Class: Facebook::Messenger::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/facebook/messenger/server.rb

Overview

This module holds the server that processes incoming messages from the Facebook Messenger Platform.

Direct Known Subclasses

ServerNoError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.call(env) ⇒ Object


20
21
22
# File 'lib/facebook/messenger/server.rb', line 20

def self.call(env)
  new.call(env)
end

Instance Method Details

#call(env) ⇒ Object

Rack handler for request.


25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/facebook/messenger/server.rb', line 25

def call(env)
  @request = Rack::Request.new(env)
  @response = Rack::Response.new

  if @request.get?
    verify
  elsif @request.post?
    receive
  else
    @response.status = 405
  end

  @response.finish
end