Sha256: c2f025ccba78cc1c784f32d238486ecd262b16b3972645e9a5cd0310ffb9b094
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
require 'rack/amf/request' require 'rack/amf/response' module Rack::AMF # Provide some helper items that can be included in the various middleware # being offered. module Middleware #:nodoc: APPLICATION_AMF = 'application/x-amf'.freeze # Standard middleware call method. Calls "handle" with the environment after # creating the request and response objects, and handles serializing the # response after the middleware is done. def call env #:nodoc: return @app.call(env) unless should_handle?(env) # Wrap request and response env['rack-amf.request'] = Request.new(env) env['rack-amf.response'] = Response.new(env['rack-amf.request']) # Call handle on "inheriting" class handle env # Calculate length and return response response = env['rack-amf.response'].to_s [200, {"Content-Type" => APPLICATION_AMF, 'Content-Length' => response.length.to_s}, [response]] end # Check if we should handle it based on the environment def should_handle? env #:nodoc: return false unless env['CONTENT_TYPE'] == APPLICATION_AMF return false if Rack::AMF::Environment.url && env['PATH_INFO'] != Rack::AMF::Environment.url true end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rack-amf-0.0.4 | lib/rack/amf/middleware.rb |
rack-amf-0.0.3 | lib/rack/amf/middleware.rb |