Class: Rack::BertRpc
- Inherits:
-
Object
- Object
- Rack::BertRpc
- Defined in:
- lib/rack/bert_rpc.rb,
lib/rack/bert_rpc/mod.rb,
lib/rack/bert_rpc/server.rb,
lib/rack/bert_rpc/version.rb,
lib/rack/bert_rpc/encoding.rb,
lib/rack/bert_rpc/server_error.rb
Defined Under Namespace
Modules: Encoding Classes: Mod, Server, ServerError
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ BertRpc
constructor
A new instance of BertRpc.
Constructor Details
#initialize(app, options = {}) ⇒ BertRpc
Returns a new instance of BertRpc.
7 8 9 10 11 12 13 14 |
# File 'lib/rack/bert_rpc.rb', line 7 def initialize(app, = {}) @path = [:path] || '/rpc' @app = app @server = [:server] || Server.new [:expose].each do |sym, mod| @server.expose(sym, mod) end unless [:expose].nil? end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/rack/bert_rpc.rb', line 5 def path @path end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/rack/bert_rpc.rb', line 16 def call(env) if path == env["PATH_INFO"] response = @server.handle(env["rack.input"]) [200, { "Content-Type" => "application/bert" }, response] else @app.call(env) end end |