Class: Pingback::Server

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

Overview

This class is intended to be used to handle pingback requests. It conforms to the rack interface. How a pingback request should be registered has to be defined in a Proc which must be supplied to the constructor.

Instance Method Summary collapse

Constructor Details

#initialize(request_handler) ⇒ Server

A new instance of Server.

Parameters:

  • request_handler (Proc, #call)

    proc which implements the pingback registration and takes the source_uri and the target_uri as params. Use the exceptions defined in Pingback to indicate errors.



15
16
17
18
# File 'lib/pingback/server.rb', line 15

def initialize(request_handler)
  @request_handler = request_handler
  setup_xmlrpc_handler
end

Instance Method Details

#call(env) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/pingback/server.rb', line 20

def call(env)

    request = Rack::Request.new(env)

    xml_response = @xmlrpc_handler.process(request.body)

    [200, {'Content-Type' => 'text/xml'}, [xml_response]]
end