Class: RESTRack::AsyncWebService
- Defined in:
- lib/restrack/async_web_service.rb
Constant Summary collapse
- AsyncResponse =
[-1, {}, []].freeze
Instance Method Summary collapse
-
#call(env) ⇒ Object
Handle requests in the Rack way.
-
#initialize ⇒ AsyncWebService
constructor
Establish the namespace pointer.
Constructor Details
permalink #initialize ⇒ AsyncWebService
Establish the namespace pointer.
22 23 24 25 |
# File 'lib/restrack/async_web_service.rb', line 22 def initialize RESTRack::CONFIG[:SERVICE_NAME] = self.class.to_s.split('::')[0].to_sym @request_hook = RESTRack::Hooks.new if RESTRack.const_defined?(:Hooks) end |
Instance Method Details
permalink #call(env) ⇒ Object
Handle requests in the Rack way.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/restrack/async_web_service.rb', line 28 def call( env ) resource_request = RESTRack::ResourceRequest.new( :request => Rack::Request.new(env) ) unless @request_hook.nil? or (RESTRack::CONFIG.has_key?(:PRE_PROCESSOR_DISABLED) and RESTRack::CONFIG[:PRE_PROCESSOR_DISABLED]) @request_hook.pre_processor(resource_request) end response = RESTRack::Response.new(resource_request) unless resource_request.requires_async_defer unless @request_hook.nil? or (RESTRack::CONFIG.has_key?(:POST_PROCESSOR_DISABLED) and RESTRack::CONFIG[:POST_PROCESSOR_DISABLED]) @request_hook.post_processor(response) end env['async.callback'].call response.output end AsyncResponse end |