Last active
August 29, 2015 14:06
-
-
Save Nyoho/bd7dae98574e7c3e43bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc "Prints out your Rack middleware stack" | |
task :middleware do | |
require 'rack' | |
options = { config: "config.ru", environment: ENV["RACK_ENV"] || "development" } | |
app = Rack::Server.new(options).send(:wrapped_app) | |
app.tap do |mw| | |
while mw | |
if mw.class == Class #&& mw.superclass == Sinatra::Base | |
puts "--- (#{mw} within) ---" | |
mw = mw.new | |
end | |
puts mw.class | |
# mw = mw.is_a?(Sinatra::ExtendedRack) ? mw.app : mw.instance_variable_get("@app") | |
mw = mw.instance_variable_get("@app") | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment