获得下令列表中间件的一般架应用程序?
-
25-09-2019 - |
题
功能我找的是类似于 rake middleware
命令在轨道,除了一架通用应用程序。
解决方案
这将返回的所有齿条应用(包括中间件)的列表:
require 'rack'
def middleware_classes(app)
r = [app]
while ((next_app = r.last.instance_variable_get(:@app)) != nil)
r << next_app
end
r.map{|e| e.instance_variable_defined?(:@app) ? e.class : e }
end
app = Rack::Builder.parse_file('config.ru').first
p middleware_classes(app)
其他提示
$ rake middleware
use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007ffd148f9468>
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use ActionDispatch::DebugExceptions
use ActionDispatch::RemoteIp
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
use ActiveRecord::Migration::CheckPending
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
run RackTest::Application.routes
http://pothibo.com/一十一分之二千〇十三/红宝石上导轨-内部-actiondispatch和 - 齿条/
不隶属于 StackOverflow