Module: Rack::AMF
- Defined in:
- lib/rack/amf.rb,
lib/rack/amf/middleware.rb,
lib/rack/amf/environment.rb
Overview
Simple rack middleware that processes amf requests as a standard AMF gateway. To use, simply run use Rack::AMF
in your rackup script. rack-amf support two options: :url
and :mode
. Setting the url makes rack-amf only handle AMF requests that match the given url. The mode can either by :service_manager
or :pass_through
, defaulting to :service_manager
.
In pass-through mode, rack-amf will set env ["rack-amf.request"]
and env ["rack-amf.response"]
. See Rack::AMF::Middleware::PassThrough
for more information.
In service-manager mode, you can register a given object to handle all method calls for a given path. AMF calls to “TestService.sayHello” will call the object’s sayHello
method and return “Hello”.
Example:
use Rack::AMF :url => "/amf"
class TestService
def sayHello
'Hello'
end
end
Rack::AMF::Environment.register_service 'TestService', TestService.new
Defined Under Namespace
Modules: Environment, Middleware
Class Method Summary collapse
-
.new(app, options = {}) ⇒ Object
:nodoc:.
Class Method Details
.new(app, options = {}) ⇒ Object
:nodoc:
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rack/amf.rb', line 34 def self.new app, ={} #:nodoc: # Set default mode [:mode] = :service_manager if ![:mode] # Which version of the middleware? if [:mode] == :pass_through require 'rack/amf/middleware/pass_through' Middleware::PassThrough.new(app, ) elsif [:mode] == :service_manager require 'rack/amf/middleware/service_manager' Middleware::ServiceManager.new(app, ) else raise "Invalide mode: #{[:mode]}" end end |