Skip to content

Commit

Permalink
Imported a simple calc-server.ru example RPC service.
Browse files Browse the repository at this point in the history
  • Loading branch information
artob committed Sep 14, 2011
1 parent ed3bd76 commit 765a927
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions doc/examples/calc-server.ru
@@ -0,0 +1,31 @@
#!/usr/bin/env rackup
$:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib')))
require 'rack/rpc'

module Calc
class Add < Rack::RPC::Operation
operand :a, Numeric
operand :b, Numeric

def execute
@a + @b
end
end

class Multiply < Rack::RPC::Operation
operand :a, Numeric
operand :b, Numeric

def execute
@a * @b
end
end

class Service < Rack::RPC::Service
operator Add
operator Multiply
end
end # Calc

use Rack::RPC::Endpoint, Calc::Service.new, :path => '/rpc'
run lambda { |env| [200, {'Content-Type' => 'text/plain', 'Location' => '/rpc'}, []] }

0 comments on commit 765a927

Please sign in to comment.