Class: BlogRPC::RackApp

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

Overview

An embeddable Rack handler for RPC servers

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(blog_handler) ⇒ RackApp

Returns a new instance of RackApp.



16
17
18
# File 'lib/blogrpc/rack_app.rb', line 16

def initialize(blog_handler)
  @handlers = [blog_handler]
end

Instance Attribute Details

#blog_urlObject

The root URL of the blog



7
8
9
# File 'lib/blogrpc/rack_app.rb', line 7

def blog_url
  @blog_url
end

#handlersObject

All the XML-RPC handlers that can respond to the request, if it so happens that you have more than one



14
15
16
# File 'lib/blogrpc/rack_app.rb', line 14

def handlers
  @handlers
end

#rpc_endpoint_urlObject

The URL of the blog API endpoint (like /backend.rpc)



10
11
12
# File 'lib/blogrpc/rack_app.rb', line 10

def rpc_endpoint_url
  @rpc_endpoint_url
end

Instance Method Details

#call(env) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/blogrpc/rack_app.rb', line 20

def call(env)
  @env = env
  req = Rack::Request.new(env)
  # If the request is a GET return the autodiscovery RSD fragment
  if req.get?
    return endpoint_xml
  else
    return post_request
  end
end