Class: WashOut::Router
- Inherits:
-
Object
- Object
- WashOut::Router
- Defined in:
- lib/wash_out/router.rb
Overview
This class is a Rack middleware used to route SOAP requests to a proper action of a given SOAP controller.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(controller_name) ⇒ Router
constructor
A new instance of Router.
Constructor Details
#initialize(controller_name) ⇒ Router
Returns a new instance of Router.
5 6 7 |
# File 'lib/wash_out/router.rb', line 5 def initialize(controller_name) @controller_name = "#{controller_name.to_s}_controller".camelize end |
Instance Method Details
#call(env) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wash_out/router.rb', line 9 def call(env) controller = @controller_name.constantize soap_action = env['HTTP_SOAPACTION'] if soap_action == '""' soap_action = env["action_dispatch.request.request_parameters"]["Envelope"]["Body"].keys.first env['wash_out.soap_action'] = soap_action elsif soap_action # RUBY18 1.8 does not have force_encoding. soap_action.force_encoding('UTF-8') if soap_action.respond_to? :force_encoding soap_action.gsub!(/^\"(.*)\"$/, '\1') env['wash_out.soap_action'] = soap_action end action_spec = controller.soap_actions[soap_action] if action_spec action = action_spec[:to] else action = '_invalid_action' end controller.action(action).call(env) end |