diff --git a/app/controllers/washout_builder/washout_builder_controller.rb b/app/controllers/washout_builder/washout_builder_controller.rb index 384b331..9cd26f8 100644 --- a/app/controllers/washout_builder/washout_builder_controller.rb +++ b/app/controllers/washout_builder/washout_builder_controller.rb @@ -31,6 +31,11 @@ def all end end + def proxy + params[:name] = request.env['washout_builder.controller_path'] + all + end + private # tries to find all services by searching through the rails controller @@ -58,7 +63,7 @@ def all_services 'documentation_url' => service_documentation_url(hash, controller_name) } end - end + end.uniq{|hash| hash['service_name'] } end def generate_wsdl_action diff --git a/lib/washout_builder.rb b/lib/washout_builder.rb index 2a8ce1f..3a910bf 100644 --- a/lib/washout_builder.rb +++ b/lib/washout_builder.rb @@ -8,7 +8,6 @@ Gem.find_files('washout_builder/**/*.rb').each { |path| require path } - ActionDispatch::Routing::Mapper.class_eval do alias_method :original_wash_out, :wash_out # Adds the routes for a SOAP endpoint at +controller+. @@ -25,9 +24,7 @@ def wash_out(controller_name, options={}) else controller_class_name = controller_name.to_s.underscore end - - match "#{controller_name}/soap_doc" => WashoutBuilder::Engine, via: :get, - defaults: { name: "#{controller_class_name}" }, + match "#{controller_name}/soap_doc" => WashoutBuilder::Router.new(controller_class_name), via: :get, format: false, as: "#{controller_class_name}_soap_doc" end diff --git a/lib/washout_builder/router.rb b/lib/washout_builder/router.rb new file mode 100644 index 0000000..03ea17c --- /dev/null +++ b/lib/washout_builder/router.rb @@ -0,0 +1,16 @@ +module WashoutBuilder + # 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_path) + @controller_path = controller_path + end + + def call(env) + env['washout_builder.controller_path'] = @controller_path + WashoutBuilderController.action(:proxy).call(env) + end + + end +end diff --git a/lib/washout_builder/version.rb b/lib/washout_builder/version.rb index efeb274..f0faa42 100644 --- a/lib/washout_builder/version.rb +++ b/lib/washout_builder/version.rb @@ -10,9 +10,9 @@ module VERSION # the major version of the gem MAJOR = 1 # the minor version of the gem - MINOR = 5 + MINOR = 6 # the tiny version of the gem - TINY = 6 + TINY = 0 # if the version should be a prerelease PRE = nil