Sha256: a69e9d09bc539bc8c023ae7d701fecb4b82bebc0dceedb3832e4c7a566cd2dd9

Contents?: true

Size: 829 Bytes

Versions: 11

Compression:

Stored size: 829 Bytes

Contents

module WashOut
  # This class is a Rack middleware used to route SOAP requests to a proper
  # action of a given SOAP controller.
  class Router
    def initialize(controller_name)
      @controller_name = "#{controller_name.to_s}_controller".camelize
    end

    def call(env)
      controller = @controller_name.constantize

      soap_action = env['HTTP_SOAPACTION']

      # 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

      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
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
wash_out-0.3.6 lib/wash_out/router.rb
wash_out-0.3.5 lib/wash_out/router.rb
wash_out-0.3.4 lib/wash_out/router.rb
wash_out-0.3.3 lib/wash_out/router.rb
wash_out-0.3.2 lib/wash_out/router.rb
wash_out-0.3.1 lib/wash_out/router.rb
wash_out-0.3.0 lib/wash_out/router.rb
wash_out-0.2.6 lib/wash_out/router.rb
wash_out-0.2.5 lib/wash_out/router.rb
wash_out-0.2.4 lib/wash_out/router.rb
wash_out-0.2.3 lib/wash_out/router.rb