Class: Rack::RPC::Endpoint
- Inherits:
-
Middleware
- Object
- Middleware
- Rack::RPC::Endpoint
- Defined in:
- lib/rack/rpc/endpoint.rb,
lib/rack/rpc/endpoint/jsonrpc.rb,
lib/rack/rpc/endpoint/xmlrpc.rb
Overview
A Rack middleware for RPC endpoints.
Defined Under Namespace
Constant Summary
- DEFAULT_PATH =
'/rpc'
Instance Attribute Summary (collapse)
- - (#call) app inherited from Middleware readonly
- - (Hash) options inherited from Middleware readonly
- - (Server) server readonly
Instance Method Summary (collapse)
- - (Array) call(env)
-
- (Endpoint) initialize(app, server, options = {})
constructor
A new instance of Endpoint.
- - (String) path
Constructor Details
- (Endpoint) initialize(app, server, options = {})
Returns a new instance of Endpoint
21 22 23 24 |
# File 'lib/rack/rpc/endpoint.rb', line 21 def initialize(app, server, = {}) @server = server super(app, ) end |
Instance Attribute Details
- (#call) app (readonly) Originally defined in class Middleware
- (Hash) options (readonly) Originally defined in class Middleware
- (Server) server (readonly)
11 12 13 |
# File 'lib/rack/rpc/endpoint.rb', line 11 def server @server end |
Instance Method Details
- (Array) call(env)
35 36 37 38 39 40 41 42 43 44 45 |
# 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 |
- (String) path
28 29 30 |
# File 'lib/rack/rpc/endpoint.rb', line 28 def path @path ||= [:path] || DEFAULT_PATH end |