[Feature Request] pass a middleware stack to Rails::Engine from the outside of Rails::Engine

Hello,

I want to pass a middleware stack to Rails::Engine like Sidekiq or Resque.

How about this implementation?


# railties/lib/rails/engine.rb

class Engine < Railtie

def self.use(*args)

if block_given?

middleware.use(*args, &Proc.new)

else

middleware.use(*args)

end

end

end

If the above method is implemented, I can use a middleware stack like this.


# [rails_root]/config/routes.rb

MyApp::Engine.use Rack::Auth::Basic do |username, password|

username == USER && password == PW

end

mount MyApp::Engine, at: '/my_app'

Sidekiq and Resque have an API as below.


Sidekiq::Web.use Rack::Auth::Basic do |username, password|

username == USER && password == PW

end

mount Sidekiq::Web, at: "/sidekiq"


Resque::Server.use Rack::Auth::Basic do |username, password|

username == USER && password == PW

end

mount Resque::Server, at: "/resque"

Thanks,

Shinohara