README.rdoc in RocketAMF-0.0.6 vs README.rdoc in RocketAMF-0.0.7

- old
+ new

@@ -6,17 +6,53 @@ gem install RocketAMF --source="http://gemcutter.org" == EXAMPLE: -NEED TO WRITE SOMETHING HERE + # helloworld.ru + require 'rocketamf' + + class HelloWorldApp + APPLICATION_AMF = 'application/x-amf'.freeze + + def call env + if is_amf?(env) + # Wrap request and response + env['rack.input'].rewind + request = RocketAMF::Request.new.populate_from_stream(env['rack.input'].read) + response = RocketAMF::Response.new + + # Handle request + response.each_method_call request do |method, args| + raise "Service #{method} does not exists" unless method == 'App.helloWorld' + 'Hello world' + end + + # Pass back response + response_str = response.serialize + return [200, {'Content-Type' => APPLICATION_AMF, 'Content-Length' => response_str.length.to_s}, [response_str]] + else + return [200, {'Content-Type' => 'text/plain', 'Content-Length' => '16' }, ["Rack AMF gateway"]] + end + end + + private + def is_amf? env + return false unless env['CONTENT_TYPE'] == APPLICATION_AMF + return false unless env['PATH_INFO'] == '/amf' + return true + end + end + + run HelloWorldApp.new + == LICENSE: (The MIT License) -Copyright (c) 2009 Tony Hillerson based on work by Aaron Smith +Copyright (c) 2009 Stephen Augenstein and Jacob Smith Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, @@ -31,6 +67,6 @@ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file