Sha256: 023b3fe159a9823fcc3f7244283cfa4761d75af99e5c73a2b6212ee5c4dd1f16

Contents?: true

Size: 698 Bytes

Versions: 5

Compression:

Stored size: 698 Bytes

Contents

module ActionDispatchJourneyRouterWithFiltering
  def find_routes(env)
    path = env.is_a?(Hash) ? env['PATH_INFO'] : env.path_info
    filter_parameters = {}
    original_path = path.dup

    @routes.filters.run(:around_recognize, path, env) do
      filter_parameters
    end

    super(env).map do |match, parameters, route|
      [ match, parameters.merge(filter_parameters), route ]
    end.tap do |match, parameters, route|
      # restore the original path
      if env.is_a?(Hash)
        env['PATH_INFO'] = original_path
      else
        env.path_info = original_path
      end
    end
  end
end

ActionDispatch::Journey::Router.send(:prepend, ActionDispatchJourneyRouterWithFiltering)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
routing-filter-0.7.0 lib/routing_filter/adapters/routers/journey.rb
routing-filter-0.6.3 lib/routing_filter/adapters/routers/journey.rb
routing-filter-0.6.2 lib/routing_filter/adapters/routers/journey.rb
routing-filter-0.6.1 lib/routing_filter/adapters/routers/journey.rb
routing-filter-0.6.0 lib/routing_filter/adapters/routers/journey.rb