module Schneiderlein
  class Engine < ::Rails::Engine
    isolate_namespace Schneiderlein

    initializer 'schneiderlein.middleware' do |app|
      app.config.middleware.insert_before \
        'ActionDispatch::ParamsParser', 'Schneiderlein::FlyCatcher'
    end
  end

end

module Schneiderlein
  class Engine < ::Rails::Engine
    isolate_namespace Schneiderlein

    initializer 'schneiderlein.middleware' do |app|
      if Rails::VERSION::MAJOR < 5
        app.config.middleware.insert_before \
          'ActionDispatch::ParamsParser', 'Schneiderlein::FlyCatcher'
      else
        # ActionDispatch::ParamsParser is not included in the middleware
        # stack anymore in Rails 5.
        app.config.middleware.insert_after \
          'ActionDispatch::Callbacks', 'Schneiderlein::FlyCatcher'
      end
    end
  end

end

Use a different fixpoint to insert Schneiderlein
Use a different fixpoint to insert Schneiderlein

ActionDispatch::Request is gone in Rails 5. By default, ActionDispatch::Request was inserted
after ActionDispatch::Callbacks so this is where we put ourselves.
