Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
bacon infused middleware
# application.rb
#
# config.middleware.use "BaconInfused"
class BaconInfused
def initialize(app)
@app = app
end
def call(env)
s, h, r = @app.call(env)
if r.content_type == 'text/html'
r.body = r.body.
gsub(/Hamburg/, 'BACON').
gsub(/src=('|")([^'|"]+).png('|")/, 'src="http://bit.ly/1maTrIt"')
end
[s, h, r]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment