class Rack::RPC::Endpoint

A Rack middleware for RPC endpoints.

Constants

DEFAULT_PATH

Attributes

server[R]

@return [Server]

Public Class Methods

new(app, server, options = {}) click to toggle source

@param [#call] app @param [Server] server @param [Hash] options

Calls superclass method
# File lib/rack/rpc/endpoint.rb, line 21
def initialize(app, server, options = {})
  @server = server
  super(app, options)
end

Public Instance Methods

call(env) click to toggle source

@param [Hash] env @return [Array]

Calls superclass method
# File lib/rack/rpc/endpoint.rb, line 35
def call(env)
  return super unless env['PATH_INFO'].eql?(path)
  return super unless env['REQUEST_METHOD'].eql?('POST')
  case content_type = env['CONTENT_TYPE']
    when %r(^application/xml), %r(^text/xml)
      XMLRPC::Server.new(server).execute(Rack::Request.new(env)).finish
    when %r(^application/json)
      JSONRPC::Server.new(server).execute(Rack::Request.new(env)).finish
    else super
  end
end
path() click to toggle source

@return [String]

# File lib/rack/rpc/endpoint.rb, line 28
def path
  @path ||= options[:path] || DEFAULT_PATH
end