Created
December 8, 2011 07:06
-
-
Save timriley/1446347 to your computer and use it in GitHub Desktop.
How to override Rack middleware so it doesn't run in certain circumstances
This file contains 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
module Rack | |
class DeflaterWithExclusions < Deflater | |
def initialize(app, options = {}) | |
@app = app | |
@exclude = options[:exclude] | |
end | |
def call(env) | |
if @exclude && @exclude.call(env) | |
@app.call(env) | |
else | |
super(env) | |
end | |
end | |
end | |
end | |
use Rack::DeflaterWithExclusions, :exclude => proc { |env| env['PATH_INFO'] == '/some/url' } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment